Skip to content

Commit 340c4ab

Browse files
Merge 25.12 to develop
2 parents fb548cd + 19ff50c commit 340c4ab

File tree

19 files changed

+124
-155
lines changed

19 files changed

+124
-155
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (c) 2011 LabKey Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.labkey.api.data;
17+
18+
import org.labkey.api.util.SkipMothershipLogging;
19+
20+
/**
21+
* Signals there was a problem with a SQL parameter, such as a conversion problem.
22+
*/
23+
public class SQLParameterException extends SQLGenerationException implements SkipMothershipLogging
24+
{
25+
public SQLParameterException(String message)
26+
{
27+
super(message);
28+
}
29+
}

api/src/org/labkey/api/data/SqlExecutingSelector.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,9 @@ public void handleSqlException(SQLException e, @Nullable Connection conn)
567567
if (null != _sql)
568568
ExceptionUtil.decorateException(e, ExceptionUtil.ExceptionInfo.DialectSQL, _sql.toDebugString(), false);
569569

570-
throw getExceptionFramework().translate(getScope(), "ExecutingSelector", e);
570+
RuntimeException translated = getExceptionFramework().translate(getScope(), "ExecutingSelector", e);
571+
ExceptionUtil.copyDecorations(e, translated);
572+
throw translated;
571573
}
572574
}
573575
}

api/src/org/labkey/api/data/Table.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.apache.commons.beanutils.BeanUtils;
2020
import org.apache.commons.beanutils.PropertyUtils;
2121
import org.apache.commons.lang3.StringUtils;
22+
import org.apache.commons.lang3.Strings;
2223
import org.apache.logging.log4j.Level;
2324
import org.apache.logging.log4j.Logger;
2425
import org.jetbrains.annotations.NotNull;
@@ -50,6 +51,7 @@
5051
import org.labkey.api.query.RuntimeValidationException;
5152
import org.labkey.api.security.User;
5253
import org.labkey.api.util.BaseScanner;
54+
import org.labkey.api.util.ExceptionUtil;
5355
import org.labkey.api.util.GUID;
5456
import org.labkey.api.util.JunitUtil;
5557
import org.labkey.api.util.MemTracker;
@@ -571,7 +573,7 @@ Object getObject(ResultSet rs) throws SQLException
571573
// Standard SQLException catch block: log exception, query SQL, and params
572574
static void logException(@Nullable SQLFragment sql, @Nullable Connection conn, SQLException e, Level logLevel)
573575
{
574-
if (SqlDialect.isCancelException(e))
576+
if (SqlDialect.isCancelException(e) || ExceptionUtil.isIgnorable(e))
575577
{
576578
return;
577579
}
@@ -585,7 +587,7 @@ static void logException(@Nullable SQLFragment sql, @Nullable Connection conn, S
585587
String trim = sql.getSQL().trim();
586588

587589
// Treat a ConstraintException during INSERT/UPDATE as a WARNING. Treat all other SQLExceptions as an ERROR.
588-
if (RuntimeSQLException.isConstraintException(e) && (StringUtils.startsWithIgnoreCase(trim, "INSERT") || StringUtils.startsWithIgnoreCase(trim, "UPDATE")))
590+
if (RuntimeSQLException.isConstraintException(e) && (Strings.CI.startsWith(trim, "INSERT") || Strings.CI.startsWith(trim, "UPDATE")))
589591
{
590592
// Log this ConstraintException if log Level is WARN (the default) or lower. Skip logging for callers that request just ERRORs.
591593
if (Level.WARN.isMoreSpecificThan(logLevel))
@@ -1409,7 +1411,7 @@ public void testSelect() throws SQLException
14091411
//noinspection EmptyTryBlock,UnusedDeclaration
14101412
try (ResultSet rs = new TableSelector(tinfo).getResultSet()){}
14111413

1412-
Map[] maps = new TableSelector(tinfo).getMapArray();
1414+
Map<?, ?>[] maps = new TableSelector(tinfo).getMapArray();
14131415
assertNotNull(maps);
14141416

14151417
Principal[] principals = new TableSelector(tinfo).getArray(Principal.class);
@@ -1739,7 +1741,7 @@ public static ParameterMapStatement deleteStatement(Connection conn, TableInfo t
17391741
//
17401742

17411743
Domain domain = tableDelete.getDomain();
1742-
DomainKind domainKind = tableDelete.getDomainKind();
1744+
DomainKind<?> domainKind = tableDelete.getDomainKind();
17431745
if (null != domain && null != domainKind && StringUtils.isEmpty(domainKind.getStorageSchemaName()))
17441746
{
17451747
if (!d.isPostgreSQL() && !d.isSqlServer())

api/src/org/labkey/api/data/TableSelector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ public Results getResultsAsync(final boolean cache, final boolean scrollable, Ht
396396
}
397397

398398
/**
399-
* Setting this options asks the TableSelector to add additional display columns to the generated SQL, as well
399+
* Setting this option asks the TableSelector to add additional display columns to the generated SQL, as well
400400
401401
* as forcing the results to be sorted.
402402
* @return this

api/src/org/labkey/api/util/ExceptionUtil.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ public class ExceptionUtil
106106
*/
107107
private static final Map<String, ExceptionTally> EXCEPTION_TALLIES = Collections.synchronizedMap(new HashMap<>());
108108

109+
public static void copyDecorations(Throwable source, Throwable target)
110+
{
111+
for (Map.Entry<Enum<?>, String> entry : getExceptionDecorations(source).entrySet())
112+
{
113+
decorateException(target, entry.getKey(), entry.getValue(), false);
114+
}
115+
}
116+
109117
private static class ExceptionTally
110118
{
111119
/** Total number of times the exception has happened */

api/src/org/labkey/api/util/SkipMothershipLogging.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,9 @@
1616

1717
package org.labkey.api.util;
1818

19-
/*
20-
* User: adam
21-
* Date: Aug 10, 2009
22-
* Time: 2:03:50 PM
23-
*/
24-
25-
// Exceptions implement this interface to tell mothership not to log them
19+
/**
20+
* Exceptions implement this interface as a tag to tell mothership not to log them
21+
*/
2622
public interface SkipMothershipLogging
2723
{
2824
}

core/src/org/labkey/core/dialect/PostgreSql92Dialect.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
abstract class PostgreSql92Dialect extends BasePostgreSqlDialect
4949
{
5050
public static final String PRODUCT_NAME = "PostgreSQL";
51-
public static final String RECOMMENDED = PRODUCT_NAME + " 17.x is the recommended version.";
5251

5352
// This has been the standard PostgreSQL identifier max byte length for many years. However, this could change in
5453
// the future plus servers can be compiled with a different limit, so we query this setting on first connection to

core/src/org/labkey/core/dialect/PostgreSqlDialectFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ else if (psv.isDeprecated())
116116

117117
public static String getStandardWarningMessage(String warning, String databaseProductVersion)
118118
{
119-
return "LabKey Server " + warning + " " + PostgreSql92Dialect.PRODUCT_NAME + " version " + databaseProductVersion + ". " + PostgreSql92Dialect.RECOMMENDED;
119+
return "LabKey Server " + warning + " " + PostgreSql92Dialect.PRODUCT_NAME + " version " + databaseProductVersion + ". " + PostgreSqlVersion.RECOMMENDED;
120120
}
121121

122122
@Override

core/src/org/labkey/core/dialect/PostgreSqlVersion.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,24 @@
1010
import java.util.function.Supplier;
1111
import java.util.stream.Collectors;
1212

13+
import static org.labkey.core.dialect.PostgreSql92Dialect.PRODUCT_NAME;
14+
1315
/**
1416
* Enum that specifies the versions of PostgreSQL that LabKey supports plus their properties
1517
*/
1618
public enum PostgreSqlVersion
1719
{
1820
POSTGRESQL_UNSUPPORTED(-1, true, false, null),
19-
POSTGRESQL_13(130, false, true, PostgreSql_13_Dialect::new),
21+
POSTGRESQL_13(130, true, true, PostgreSql_13_Dialect::new),
2022
POSTGRESQL_14(140, false, true, PostgreSql_14_Dialect::new),
2123
POSTGRESQL_15(150, false, true, PostgreSql_15_Dialect::new),
2224
POSTGRESQL_16(160, false, true, PostgreSql_16_Dialect::new),
2325
POSTGRESQL_17(170, false, true, PostgreSql_17_Dialect::new),
24-
POSTGRESQL_18(180, false, false, PostgreSql_18_Dialect::new),
26+
POSTGRESQL_18(180, false, true, PostgreSql_18_Dialect::new),
2527
POSTGRESQL_FUTURE(Integer.MAX_VALUE, true, false, PostgreSql_18_Dialect::new);
2628

29+
public static final String RECOMMENDED = PRODUCT_NAME + " 18.x is the recommended version.";
30+
2731
private final int _version;
2832
private final boolean _deprecated;
2933
private final boolean _tested;

query/src/org/labkey/query/QueryServiceImpl.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.commons.collections4.MultiValuedMap;
2424
import org.apache.commons.collections4.SetValuedMap;
2525
import org.apache.commons.lang3.StringUtils;
26+
import org.apache.commons.lang3.Strings;
2627
import org.apache.logging.log4j.LogManager;
2728
import org.apache.logging.log4j.Logger;
2829
import org.apache.xmlbeans.XmlError;
@@ -65,7 +66,7 @@
6566
import org.labkey.api.data.ResultsImpl;
6667
import org.labkey.api.data.RuntimeSQLException;
6768
import org.labkey.api.data.SQLFragment;
68-
import org.labkey.api.data.SQLGenerationException;
69+
import org.labkey.api.data.SQLParameterException;
6970
import org.labkey.api.data.SimpleFilter;
7071
import org.labkey.api.data.Sort;
7172
import org.labkey.api.data.SqlSelector;
@@ -120,6 +121,7 @@
120121
import org.labkey.api.util.CSRFUtil;
121122
import org.labkey.api.util.ConfigurationException;
122123
import org.labkey.api.util.ContainerContext;
124+
import org.labkey.api.util.ExceptionUtil;
123125
import org.labkey.api.util.GUID;
124126
import org.labkey.api.util.JunitUtil;
125127
import org.labkey.api.util.Pair;
@@ -1360,7 +1362,7 @@ public MultiValuedMap<Path, ModuleCustomViewDef> load(Stream<? extends Resource>
13601362
{
13611363
// Note: Can't use standard filter (getFilter(suffix)) below since we must allow ".qview.xml"
13621364
return unmodifiable(resources
1363-
.filter(resource -> StringUtils.endsWithIgnoreCase(resource.getName(), CustomViewXmlReader.XML_FILE_EXTENSION))
1365+
.filter(resource -> Strings.CI.endsWith(resource.getName(), CustomViewXmlReader.XML_FILE_EXTENSION))
13641366
.map(ModuleCustomViewDef::new)
13651367
.collect(LabKeyCollectors.toMultiValuedMap(def -> def.getPath().getParent(), def -> def)));
13661368
}
@@ -2683,7 +2685,9 @@ public void bindNamedParameters(SQLFragment frag, @Nullable Map<String, Object>
26832685
}
26842686
catch (ConversionException e)
26852687
{
2686-
throw new RuntimeSQLException(new SQLGenerationException(ConvertHelper.getStandardConversionErrorMessage(value, p.getName(), p.getJdbcType().getJavaClass())));
2688+
SQLParameterException paramException = new SQLParameterException(ConvertHelper.getStandardConversionErrorMessage(value, p.getName(), p.getJdbcType().getJavaClass()));
2689+
ExceptionUtil.decorateException(paramException, ExceptionUtil.ExceptionInfo.SkipMothershipLogging, "true", true);
2690+
throw new RuntimeSQLException(paramException);
26872691
}
26882692
}
26892693
}

0 commit comments

Comments
 (0)