This is an automated email from the ASF dual-hosted git repository. rmaucher pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 04b3e59beff18989cf13ac4595185039351042b4 Author: opencode <[email protected]> AuthorDate: Tue Dec 1 23:19:35 2026 +0100 Refactor duplicated credential, publish and warning logic Extract shared credential staging in PooledConnection, shared busy-queue publishing in ConnectionPool, and shared interceptor property warning helpers in JdbcInterceptor. Replace the manual field list in PoolProperties.copyOf with reflective field copying plus explicit deep copies of the mutable collections and arrays, keeping scalar fields in step automatically. Add a message for a snapshot copy failure. mvn test passes: 1187 tests, 0 failures. --- .../apache/tomcat/jdbc/pool/ConnectionPool.java | 100 ++++++++---------- .../apache/tomcat/jdbc/pool/JdbcInterceptor.java | 63 ++++++++++++ .../apache/tomcat/jdbc/pool/PoolProperties.java | 113 +++++++++------------ .../apache/tomcat/jdbc/pool/PooledConnection.java | 48 ++++----- .../jdbc/pool/interceptor/ResetAbandonedTimer.java | 9 +- .../jdbc/pool/interceptor/StatementCache.java | 53 +--------- .../jdbc/pool/interceptor/StatementFinalizer.java | 15 +-- .../tomcat/jdbc/pool/util/LocalStrings.properties | 1 + 8 files changed, 187 insertions(+), 215 deletions(-) diff --git a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java index eeb4782ad2..2a7a103b85 100644 --- a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java +++ b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java @@ -2044,6 +2044,35 @@ public class ConnectionPool { } } + /** + * Stamps and publishes a connection for the hand-off to a borrower. The timestamp is taken at the hand-off, not at + * the borrow loop's entry, so the abandoned check does not count time a borrower spent waiting for the connection. + * An offer failure is only a tracing limitation and does not fail the hand-off. If the pool closed between the + * offer and the check, the offer is retracted and the method returns {@code false}; the caller must retire the + * connection. + * + * @param con the connection being handed off + * + * @return {@code true} when the connection was published, {@code false} when it was retracted because the pool + * closed + */ + private boolean publishBorrowedConnection(PooledConnection con) { + con.setTimestamp(System.currentTimeMillis()); + if (poolProperties.isLogAbandoned()) { + con.setStackTraceElements(getThreadDumpElements()); + } + if (!busy.offer(con)) { + log.debug("Connection doesn't fit into busy array, connection will not be traceable."); + return true; + } + if (isClosed()) { + busy.remove(con); + return false; + } + return true; + } + + /** * Creates a JDBC connection and tries to connect to the database. * @@ -2094,26 +2123,9 @@ public class ConnectionPool { throw new SQLException(MessageFactory.get("connectionPool.poolClosed")); } if (con.validate(PooledConnection.VALIDATE_INIT)) { - // Stamped with the moment of the hand-off, not with the - // borrow loop's entry: checkAbandoned() measures the checkout - // age from this timestamp, and a connection created at the - // end of a long wait must not be born already past the - // abandon timeout. - con.setTimestamp(System.currentTimeMillis()); - if (poolProperties.isLogAbandoned()) { - con.setStackTraceElements(getThreadDumpElements()); - } - if (!busy.offer(con)) { - log.debug("Connection doesn't fit into busy array, connection will not be traceable."); - } else if (isClosed()) { - // The closed check above and this publish are not one - // atomic step: a forced close may already have drained - // busy, and this entry would sit there unseen while the - // borrower is handed a connection from a dead pool. - // Retract the publish and fail the borrow the way the - // check does; the error path below disconnects the - // session, or finds the drain already disconnected it. - busy.remove(con); + // Stamp and publish at the hand-off; the error path below + // retires a connection whose publish raced the closure. + if (!publishBorrowedConnection(con)) { throw new SQLException(MessageFactory.get("connectionPool.poolClosed")); } return con; @@ -2186,29 +2198,11 @@ public class ConnectionPool { if (!forceReconnect) { if ((!con.isDiscarded()) && con.validate(PooledConnection.VALIDATE_BORROW)) { - // Stamp the checkout with this hand-off moment, not the - // borrow loop's entry: the abandoned check measures the - // time since here, and a borrower that queued longer - // than the abandon timeout must not be born abandoned. - con.setTimestamp(System.currentTimeMillis()); - if (poolProperties.isLogAbandoned()) { - con.setStackTraceElements(getThreadDumpElements()); - } - if (!busy.offer(con)) { - log.debug("Connection doesn't fit into busy array, connection will not be traceable."); - } else if (isClosed()) { - // The close this path races had already drained busy - // once when this offer landed, and - unlike the - // returning thread, which reclaims what it offered - // too late - this publish would hand the session to - // the borrower over a pool that has shut down: the - // return that handed this connection over lets it go - // precisely because it trusts the taker to see to the - // connection's closure. Retract the publish and - // retire the connection; the borrow loop's own closed - // re-check turns this into the failure a closed pool - // owes the borrower. - busy.remove(con); + if (!publishBorrowedConnection(con)) { + // The publish raced the closure: retract and retire, + // and let the borrow loop's own closed re-check turn + // this into the failure a closed pool owes the + // borrower. release(con); setToNull = true; return null; @@ -2255,22 +2249,10 @@ public class ConnectionPool { int validationMode = isInitNewConnections() ? PooledConnection.VALIDATE_INIT : PooledConnection.VALIDATE_BORROW; if (con.validate(validationMode)) { - // Same hand-off stamping as the validate-pass branch - // above: the abandoned check measures the time since this - // moment, not since the borrow loop's entry. - con.setTimestamp(System.currentTimeMillis()); - if (poolProperties.isLogAbandoned()) { - con.setStackTraceElements(getThreadDumpElements()); - } - if (!busy.offer(con)) { - log.debug("Connection doesn't fit into busy array, connection will not be traceable."); - } else if (isClosed()) { - // Same closed-versus-publish race as in the - // validate-pass branch above: retract the offer and - // retire the connection, and let the borrow loop's - // own closed re-check turn this into the failure a - // closed pool owes the borrower. - busy.remove(con); + if (!publishBorrowedConnection(con)) { + // Same closed-versus-publish race as the validate-pass + // branch: retract and retire, and let the borrow + // loop's own closed re-check report the closure. release(con); setToNull = true; return null; diff --git a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java index 43435681dc..d84959416c 100644 --- a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java +++ b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java @@ -19,8 +19,11 @@ package org.apache.tomcat.jdbc.pool; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.util.Map; +import java.util.function.Predicate; +import org.apache.juli.logging.Log; import org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorProperty; +import org.apache.tomcat.jdbc.pool.util.MessageFactory; /** * Abstract class that is to be extended for implementations of interceptors. When an operation is called on the @@ -250,6 +253,66 @@ public abstract class JdbcInterceptor implements InvocationHandler { } } + /** + * Warns about every configured property name the predicate does not recognize. The value is deliberately not + * logged: an unknown property may have been meant to carry a credential. + * + * @param properties the configured properties + * @param known the predicate that recognizes a property name + * @param log the interceptor's logger + * @param messageKey the message key naming the interceptor + */ + protected static void warnUnknownProperties(Map<String, InterceptorProperty> properties, + Predicate<String> known, Log log, String messageKey) { + for (Map.Entry<String, InterceptorProperty> entry : properties.entrySet()) { + if (!known.test(entry.getKey())) { + log.warn(MessageFactory.get(messageKey, entry.getKey())); + } + } + } + + + /** + * Warns when a boolean property was supplied with a value the property parser does not recognize. The parser keeps + * the current value silently, which hides a configuration typo. The supplied value is not logged because it may be + * a credential. + * + * @param log the interceptor's logger + * @param name the property name + * @param property the supplied property + * @param current the value that will be kept + */ + protected static void warnInvalidBoolean(Log log, String name, InterceptorProperty property, boolean current) { + String value = property.getValue(); + if (value != null && !"true".equalsIgnoreCase(value.trim()) + && !"false".equalsIgnoreCase(value.trim())) { + log.warn(MessageFactory.get("interceptor.invalidBooleanProperty", name, Boolean.valueOf(current))); + } + } + + + /** + * Warns when an integer property was supplied with a value the property parser cannot read. The parser keeps the + * current value silently, which hides a configuration typo. The supplied value is not logged because it may be a + * credential. + * + * @param log the interceptor's logger + * @param name the property name + * @param property the supplied property + * @param current the value that will be kept + */ + protected static void warnInvalidInteger(Log log, String name, InterceptorProperty property, int current) { + String value = property.getValue(); + if (value != null) { + try { + Integer.parseInt(value.trim()); + } catch (NumberFormatException x) { + log.warn(MessageFactory.get("interceptor.invalidIntegerProperty", name, Integer.valueOf(current))); + } + } + } + + /** * True if the compare method uses the Object.equals(Object) method, false if comparison is done on a reference * level. diff --git a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java index 30046f7b8a..111329db4b 100644 --- a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java +++ b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java @@ -21,7 +21,9 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.io.StringReader; +import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -2856,74 +2858,59 @@ public class PoolProperties implements PoolConfiguration, Cloneable, Serializabl // of another generation. synchronized (from) { PoolProperties copy = new PoolProperties(from.name); - copy.dbProperties = from.dbProperties == null ? null : PoolUtilities.clone(from.dbProperties); - copy.url = from.url; - copy.driverClassName = from.driverClassName; - copy.defaultAutoCommit = from.defaultAutoCommit; - copy.defaultReadOnly = from.defaultReadOnly; - copy.defaultTransactionIsolation = from.defaultTransactionIsolation; - copy.defaultCatalog = from.defaultCatalog; - copy.connectionProperties = from.connectionProperties; - copy.connectionPropertyKeys = from.connectionPropertyKeys == null ? null - : new HashSet<>(from.connectionPropertyKeys); - copy.initialSize = from.initialSize; - copy.maxActive = from.maxActive; - copy.maxIdle = from.maxIdle; - copy.minIdle = from.minIdle; - copy.maxWait = from.maxWait; - copy.validationQuery = from.validationQuery; - copy.validationQueryTimeout = from.validationQueryTimeout; - copy.validatorClassName = from.validatorClassName; - copy.validator = from.validator; - copy.testOnBorrow = from.testOnBorrow; - copy.testOnReturn = from.testOnReturn; - copy.testWhileIdle = from.testWhileIdle; - copy.timeBetweenEvictionRunsMillis = from.timeBetweenEvictionRunsMillis; - copy.numTestsPerEvictionRun = from.numTestsPerEvictionRun; - copy.minEvictableIdleTimeMillis = from.minEvictableIdleTimeMillis; - copy.accessToUnderlyingConnectionAllowed = from.accessToUnderlyingConnectionAllowed; - copy.removeAbandoned = from.removeAbandoned; - copy.removeAbandonedTimeout = from.removeAbandonedTimeout; - copy.logAbandoned = from.logAbandoned; - copy.password = from.password; - copy.passwordCleared = from.passwordCleared; - copy.username = from.username; - copy.usernameCleared = from.usernameCleared; - copy.validationInterval = from.validationInterval; - copy.jmxEnabled = from.jmxEnabled; - copy.initSQL = from.initSQL; - copy.initSQLs = from.initSQLs == null ? null : from.initSQLs.clone(); - copy.testOnConnect = from.testOnConnect; - copy.jdbcInterceptors = from.jdbcInterceptors; - copy.fairQueue = from.fairQueue; - copy.useEquals = from.useEquals; - copy.abandonWhenPercentageFull = from.abandonWhenPercentageFull; - copy.maxAge = from.maxAge; - copy.useLock = from.useLock; - if (from.interceptors != null) { - InterceptorDefinition[] copies = new InterceptorDefinition[from.interceptors.length]; - for (int i = 0; i < from.interceptors.length; i++) { - copies[i] = from.interceptors[i] == null ? null : from.interceptors[i].copy(); - } - copy.interceptors = copies; - } - copy.suspectTimeout = from.suspectTimeout; - copy.dataSource = from.dataSource; - copy.dataSourceJNDI = from.dataSourceJNDI; - copy.alternateUsernameAllowed = from.alternateUsernameAllowed; - copy.commitOnReturn = from.commitOnReturn; - copy.rollbackOnReturn = from.rollbackOnReturn; - copy.rollbackOnAbandon = from.rollbackOnAbandon; - copy.useDisposableConnectionFacade = from.useDisposableConnectionFacade; - copy.logValidationErrors = from.logValidationErrors; - copy.propagateInterruptState = from.propagateInterruptState; - copy.ignoreExceptionOnPreLoad = from.ignoreExceptionOnPreLoad; - copy.useStatementFacade = from.useStatementFacade; + copyFields(copy, from); return copy; } } + /** + * Copies every non-static field of the plain configuration into the target. Reflection keeps scalar fields in step + * with the class automatically; the mutable collections and arrays need explicit deep copies. The caller holds the + * source monitor. + * + * @param target the plain copy to populate + * @param source the configuration to copy + */ + private static void copyFields(PoolProperties target, PoolProperties source) { + try { + for (Field field : PoolProperties.class.getDeclaredFields()) { + if (Modifier.isStatic(field.getModifiers())) { + continue; + } + field.setAccessible(true); + Object value = field.get(source); + switch (field.getName()) { + case "dbProperties": + value = value == null ? null : PoolUtilities.clone((Properties) value); + break; + case "connectionPropertyKeys": + value = value == null ? null : new HashSet<>((Set<?>) value); + break; + case "initSQLs": + value = value == null ? null : ((String[]) value).clone(); + break; + case "interceptors": + InterceptorDefinition[] definitions = (InterceptorDefinition[]) value; + if (definitions != null) { + InterceptorDefinition[] copies = new InterceptorDefinition[definitions.length]; + for (int i = 0; i < definitions.length; i++) { + copies[i] = definitions[i] == null ? null : definitions[i].copy(); + } + value = copies; + } + break; + default: + break; + } + field.set(target, value); + } + } catch (IllegalAccessException x) { + throw new IllegalStateException(MessageFactory.get("poolProperties.snapshotCopyFailed"), x); + } + } + + /** * Returns a copy of the configuration, including a copy of the driver-properties collection so a defaults-backed * property resolves on the copy too, and independent copies of the parsed interceptor definitions and their diff --git a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PooledConnection.java b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PooledConnection.java index d0418675f6..7f0eb10626 100644 --- a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PooledConnection.java +++ b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PooledConnection.java @@ -443,6 +443,26 @@ public class PooledConnection implements PooledConnectionMBean { return false; } + /** + * Returns a credential staged in the attribute map, or stores and returns the configured value when the attribute + * is absent. A present entry is authoritative even when its value is null; only the absence of the key falls back + * to the configuration. + * + * @param key the attribute key + * @param configuredValue the configuration value to stage when the attribute is absent + * + * @return the staged or configured credential + */ + private String attributeOrConfiguredCredential(String key, String configuredValue) { + Map<Object, Object> attributes = getAttributes(); + if (attributes.containsKey(key)) { + return (String) attributes.get(key); + } + attributes.put(key, configuredValue); + return configuredValue; + } + + /** * Connects using the configured DataSource. * @@ -468,18 +488,8 @@ public class PooledConnection implements PooledConnectionMBean { // snapshot is immutable, so the same block only makes the read atomic // for a custom configuration. synchronized (configuration) { - if (getAttributes().containsKey(PROP_USER)) { - usr = (String) getAttributes().get(PROP_USER); - } else { - usr = configuration.getUsername(); - getAttributes().put(PROP_USER, usr); - } - if (getAttributes().containsKey(PROP_PASSWORD)) { - pwd = (String) getAttributes().get(PROP_PASSWORD); - } else { - pwd = configuration.getPassword(); - getAttributes().put(PROP_PASSWORD, pwd); - } + usr = attributeOrConfiguredCredential(PROP_USER, configuration.getUsername()); + pwd = attributeOrConfiguredCredential(PROP_PASSWORD, configuration.getPassword()); } Object dataSource = configuration.getDataSource(); if (dataSource instanceof javax.sql.XADataSource) { @@ -718,18 +728,8 @@ public class PooledConnection implements PooledConnectionMBean { } else { properties = PoolUtilities.clone(dbProperties); } - if (getAttributes().containsKey(PROP_USER)) { - usr = (String) getAttributes().get(PROP_USER); - } else { - usr = configuration.getUsername(); - getAttributes().put(PROP_USER, usr); - } - if (getAttributes().containsKey(PROP_PASSWORD)) { - pwd = (String) getAttributes().get(PROP_PASSWORD); - } else { - pwd = configuration.getPassword(); - getAttributes().put(PROP_PASSWORD, pwd); - } + usr = attributeOrConfiguredCredential(PROP_USER, configuration.getUsername()); + pwd = attributeOrConfiguredCredential(PROP_PASSWORD, configuration.getPassword()); } // The overlay is the credential setters' every-spelling rule at the // last boundary: while a credential field is set its value replaces diff --git a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/ResetAbandonedTimer.java b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/ResetAbandonedTimer.java index d144f1a4c4..bab110dcc5 100644 --- a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/ResetAbandonedTimer.java +++ b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/ResetAbandonedTimer.java @@ -93,13 +93,8 @@ public class ResetAbandonedTimer extends AbstractQueryReport implements ResetAba @Override public void setProperties(Map<String, InterceptorProperty> properties) { super.setProperties(properties); - for (Map.Entry<String, InterceptorProperty> entry : properties.entrySet()) { - if (!"useEquals".equals(entry.getKey())) { - // The value is not logged: an unknown property may have been - // meant to carry a credential. - log.warn(MessageFactory.get("resetAbandonedTimer.unknownProperty", entry.getKey())); - } - } + warnUnknownProperties(properties, name -> "useEquals".equals(name), log, + "resetAbandonedTimer.unknownProperty"); } @Override diff --git a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/StatementCache.java b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/StatementCache.java index 6731d43464..55511f5826 100644 --- a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/StatementCache.java +++ b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/StatementCache.java @@ -176,26 +176,20 @@ public class StatementCache extends StatementDecoratorInterceptor implements Sta @Override public void setProperties(Map<String, InterceptorProperty> properties) { super.setProperties(properties); - for (Map.Entry<String, InterceptorProperty> entry : properties.entrySet()) { - if (!isKnownProperty(entry.getKey())) { - // The value is not logged: an unknown property may have been - // meant to carry a credential. - log.warn(MessageFactory.get("statementCache.unknownProperty", entry.getKey())); - } - } + warnUnknownProperties(properties, this::isKnownProperty, log, "statementCache.unknownProperty"); InterceptorProperty p = properties.get("prepared"); if (p != null) { - warnInvalidBoolean("prepared", p, cachePrepared); + warnInvalidBoolean(log, "prepared", p, cachePrepared); cachePrepared = p.getValueAsBoolean(cachePrepared); } p = properties.get("callable"); if (p != null) { - warnInvalidBoolean("callable", p, cacheCallable); + warnInvalidBoolean(log, "callable", p, cacheCallable); cacheCallable = p.getValueAsBoolean(cacheCallable); } p = properties.get("max"); if (p != null) { - warnInvalidInteger("max", p, maxCacheSize); + warnInvalidInteger(log, "max", p, maxCacheSize); maxCacheSize = p.getValueAsInt(maxCacheSize); } if (cachePrepared && cacheCallable) { @@ -223,45 +217,6 @@ public class StatementCache extends StatementDecoratorInterceptor implements Sta || "useEquals".equals(name); } - /** - * Warns when a boolean property was supplied with a value the property parser does not recognise. The parser keeps - * the current value silently, which hides a configuration typo. The supplied value is not logged because it may be - * a credential. - * - * @param name the property name - * @param property the supplied property - * @param current the value that will be kept - */ - private void warnInvalidBoolean(String name, InterceptorProperty property, boolean current) { - String value = property.getValue(); - if (value != null && !"true".equalsIgnoreCase(value.trim()) - && !"false".equalsIgnoreCase(value.trim())) { - log.warn(MessageFactory.get("interceptor.invalidBooleanProperty", name, - Boolean.valueOf(current))); - } - } - - /** - * Warns when an integer property was supplied with a value the property parser cannot read. The parser keeps the - * current value silently, which hides a configuration typo. The supplied value is not logged because it may be a - * credential. - * - * @param name the property name - * @param property the supplied property - * @param current the value that will be kept - */ - private void warnInvalidInteger(String name, InterceptorProperty property, int current) { - String value = property.getValue(); - if (value != null) { - try { - Integer.parseInt(value.trim()); - } catch (NumberFormatException x) { - log.warn(MessageFactory.get("interceptor.invalidIntegerProperty", name, - Integer.valueOf(current))); - } - } - } - private static final Map<ConnectionPool, AtomicInteger> cacheSizeMap = Collections.synchronizedMap(new WeakHashMap<ConnectionPool, AtomicInteger>()); diff --git a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/StatementFinalizer.java b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/StatementFinalizer.java index debc139027..258768b24e 100644 --- a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/StatementFinalizer.java +++ b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/StatementFinalizer.java @@ -197,22 +197,11 @@ public class StatementFinalizer extends AbstractCreateStatementInterceptor { @Override public void setProperties(Map<String, PoolProperties.InterceptorProperty> properties) { super.setProperties(properties); - for (Map.Entry<String, PoolProperties.InterceptorProperty> entry : properties.entrySet()) { - if (!isKnownProperty(entry.getKey())) { - // The value is not logged: an unknown property may have been - // meant to carry a credential. - log.warn(MessageFactory.get("statementFinalizer.unknownProperty", entry.getKey())); - } - } + warnUnknownProperties(properties, this::isKnownProperty, log, "statementFinalizer.unknownProperty"); PoolProperties.InterceptorProperty logProperty = properties.get("trace"); if (null != logProperty) { - String value = logProperty.getValue(); - if (value != null && !"true".equals(value) && !"false".equals(value)) { - // The supplied value is not logged: it may be a credential. - log.warn(MessageFactory.get("interceptor.invalidBooleanProperty", "trace", - Boolean.valueOf(logCreationStack))); - } + warnInvalidBoolean(log, "trace", logProperty, logCreationStack); logCreationStack = logProperty.getValueAsBoolean(logCreationStack); } } diff --git a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/util/LocalStrings.properties b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/util/LocalStrings.properties index 183040a9fd..0527453e57 100644 --- a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/util/LocalStrings.properties +++ b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/util/LocalStrings.properties @@ -179,6 +179,7 @@ poolProperties.invalidInterceptorProperty=Invalid interceptor property ''{0}'', poolProperties.invalidInterceptorDefinition=Invalid interceptor definition [{0}]: parentheses must be balanced and no text may follow the closing parenthesis poolProperties.credentialClearStripsStringEntry=Clearing the ''{0}'' credential also removed the entry the connectionProperties string contributes for that key. The string still names it, so every connection established from now on goes without that credential, and a connectionProperties reconfigure that re-names the key applies it again. Take the credential out of the connectionProperties string to retire it. poolProperties.invalidConnectionProperties=Unable to parse the connection properties string: {0} +poolProperties.snapshotCopyFailed=Unable to snapshot the PoolProperties configuration. poolProperties.interceptorPropertyNameRequired=The name of an interceptor property cannot be null. poolProperties.layeredPoolsNotAllowed=Layered pools are not allowed. poolProperties.displayConfigurationNotAllowed=The supplied configuration is a display-only bean/JMX view and cannot be used to create a pool; use the underlying PoolProperties instead. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
