Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/PerUserPoolDataSource.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/PerUserPoolDataSource.java?rev=1743719&r1=1743718&r2=1743719&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/PerUserPoolDataSource.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/PerUserPoolDataSource.java Fri May 13 18:49:32 2016 @@ -102,10 +102,10 @@ public class PerUserPoolDataSource exten */ @Override public void close() { - for (PooledConnectionManager manager : managers.values()) { + for (final PooledConnectionManager manager : managers.values()) { try { ((CPDSConnectionFactory) manager).getPool().close(); - } catch (Exception closePoolException) { + } catch (final Exception closePoolException) { //ignore and try to close others. } } @@ -122,7 +122,7 @@ public class PerUserPoolDataSource exten * @param key The user * @return <code>true</code> to block */ - public boolean getPerUserBlockWhenExhausted(String key) { + public boolean getPerUserBlockWhenExhausted(final String key) { Boolean value = null; if (perUserBlockWhenExhausted != null) { value = perUserBlockWhenExhausted.get(key); @@ -140,8 +140,8 @@ public class PerUserPoolDataSource exten * @param username The user * @param value The value */ - public void setPerUserBlockWhenExhausted(String username, - Boolean value) { + public void setPerUserBlockWhenExhausted(final String username, + final Boolean value) { assertInitializationAllowed(); if (perUserBlockWhenExhausted == null) { perUserBlockWhenExhausted = new HashMap<>(); @@ -150,7 +150,7 @@ public class PerUserPoolDataSource exten } void setPerUserBlockWhenExhausted( - Map<String,Boolean> userDefaultBlockWhenExhausted) { + final Map<String,Boolean> userDefaultBlockWhenExhausted) { assertInitializationAllowed(); if (perUserBlockWhenExhausted == null) { perUserBlockWhenExhausted = new HashMap<>(); @@ -168,7 +168,7 @@ public class PerUserPoolDataSource exten * @param key The user * @return the policy class name */ - public String getPerUserEvictionPolicyClassName(String key) { + public String getPerUserEvictionPolicyClassName(final String key) { String value = null; if (perUserEvictionPolicyClassName != null) { value = perUserEvictionPolicyClassName.get(key); @@ -186,8 +186,8 @@ public class PerUserPoolDataSource exten * @param username The user * @param value The value */ - public void setPerUserEvictionPolicyClassName(String username, - String value) { + public void setPerUserEvictionPolicyClassName(final String username, + final String value) { assertInitializationAllowed(); if (perUserEvictionPolicyClassName == null) { perUserEvictionPolicyClassName = new HashMap<>(); @@ -196,7 +196,7 @@ public class PerUserPoolDataSource exten } void setPerUserEvictionPolicyClassName( - Map<String,String> userDefaultEvictionPolicyClassName) { + final Map<String,String> userDefaultEvictionPolicyClassName) { assertInitializationAllowed(); if (perUserEvictionPolicyClassName == null) { perUserEvictionPolicyClassName = new HashMap<>(); @@ -214,7 +214,7 @@ public class PerUserPoolDataSource exten * @param key The user * @return <code>true</code> to use LIFO */ - public boolean getPerUserLifo(String key) { + public boolean getPerUserLifo(final String key) { Boolean value = null; if (perUserLifo != null) { value = perUserLifo.get(key); @@ -232,7 +232,7 @@ public class PerUserPoolDataSource exten * @param username The user * @param value The value */ - public void setPerUserLifo(String username, Boolean value) { + public void setPerUserLifo(final String username, final Boolean value) { assertInitializationAllowed(); if (perUserLifo == null) { perUserLifo = new HashMap<>(); @@ -240,7 +240,7 @@ public class PerUserPoolDataSource exten perUserLifo.put(username, value); } - void setPerUserLifo(Map<String,Boolean> userDefaultLifo) { + void setPerUserLifo(final Map<String,Boolean> userDefaultLifo) { assertInitializationAllowed(); if (perUserLifo == null) { perUserLifo = new HashMap<>(); @@ -258,7 +258,7 @@ public class PerUserPoolDataSource exten * @param key The user * @return the maximum idle */ - public int getPerUserMaxIdle(String key) { + public int getPerUserMaxIdle(final String key) { Integer value = null; if (perUserMaxIdle != null) { value = perUserMaxIdle.get(key); @@ -276,7 +276,7 @@ public class PerUserPoolDataSource exten * @param username The user * @param value The value */ - public void setPerUserMaxIdle(String username, Integer value) { + public void setPerUserMaxIdle(final String username, final Integer value) { assertInitializationAllowed(); if (perUserMaxIdle == null) { perUserMaxIdle = new HashMap<>(); @@ -284,7 +284,7 @@ public class PerUserPoolDataSource exten perUserMaxIdle.put(username, value); } - void setPerUserMaxIdle(Map<String,Integer> userDefaultMaxIdle) { + void setPerUserMaxIdle(final Map<String,Integer> userDefaultMaxIdle) { assertInitializationAllowed(); if (perUserMaxIdle == null) { perUserMaxIdle = new HashMap<>(); @@ -302,7 +302,7 @@ public class PerUserPoolDataSource exten * @param key The user * @return the maximum total */ - public int getPerUserMaxTotal(String key) { + public int getPerUserMaxTotal(final String key) { Integer value = null; if (perUserMaxTotal != null) { value = perUserMaxTotal.get(key); @@ -320,7 +320,7 @@ public class PerUserPoolDataSource exten * @param username The user * @param value The value */ - public void setPerUserMaxTotal(String username, Integer value) { + public void setPerUserMaxTotal(final String username, final Integer value) { assertInitializationAllowed(); if (perUserMaxTotal == null) { perUserMaxTotal = new HashMap<>(); @@ -328,7 +328,7 @@ public class PerUserPoolDataSource exten perUserMaxTotal.put(username, value); } - void setPerUserMaxTotal(Map<String,Integer> userDefaultMaxTotal) { + void setPerUserMaxTotal(final Map<String,Integer> userDefaultMaxTotal) { assertInitializationAllowed(); if (perUserMaxTotal == null) { perUserMaxTotal = new HashMap<>(); @@ -346,7 +346,7 @@ public class PerUserPoolDataSource exten * @param key The user * @return the maximum wait time */ - public long getPerUserMaxWaitMillis(String key) { + public long getPerUserMaxWaitMillis(final String key) { Long value = null; if (perUserMaxWaitMillis != null) { value = perUserMaxWaitMillis.get(key); @@ -364,7 +364,7 @@ public class PerUserPoolDataSource exten * @param username The user * @param value The value */ - public void setPerUserMaxWaitMillis(String username, Long value) { + public void setPerUserMaxWaitMillis(final String username, final Long value) { assertInitializationAllowed(); if (perUserMaxWaitMillis == null) { perUserMaxWaitMillis = new HashMap<>(); @@ -373,7 +373,7 @@ public class PerUserPoolDataSource exten } void setPerUserMaxWaitMillis( - Map<String,Long> userDefaultMaxWaitMillis) { + final Map<String,Long> userDefaultMaxWaitMillis) { assertInitializationAllowed(); if (perUserMaxWaitMillis == null) { perUserMaxWaitMillis = new HashMap<>(); @@ -391,7 +391,7 @@ public class PerUserPoolDataSource exten * @param key The user * @return the minimum idle time for eviction */ - public long getPerUserMinEvictableIdleTimeMillis(String key) { + public long getPerUserMinEvictableIdleTimeMillis(final String key) { Long value = null; if (perUserMinEvictableIdleTimeMillis != null) { value = perUserMinEvictableIdleTimeMillis.get(key); @@ -409,8 +409,8 @@ public class PerUserPoolDataSource exten * @param username The user * @param value The value */ - public void setPerUserMinEvictableIdleTimeMillis(String username, - Long value) { + public void setPerUserMinEvictableIdleTimeMillis(final String username, + final Long value) { assertInitializationAllowed(); if (perUserMinEvictableIdleTimeMillis == null) { perUserMinEvictableIdleTimeMillis = new HashMap<>(); @@ -419,7 +419,7 @@ public class PerUserPoolDataSource exten } void setPerUserMinEvictableIdleTimeMillis( - Map<String,Long> userDefaultMinEvictableIdleTimeMillis) { + final Map<String,Long> userDefaultMinEvictableIdleTimeMillis) { assertInitializationAllowed(); if (perUserMinEvictableIdleTimeMillis == null) { perUserMinEvictableIdleTimeMillis = new HashMap<>(); @@ -438,7 +438,7 @@ public class PerUserPoolDataSource exten * @param key The user * @return the minimum idle count */ - public int getPerUserMinIdle(String key) { + public int getPerUserMinIdle(final String key) { Integer value = null; if (perUserMinIdle != null) { value = perUserMinIdle.get(key); @@ -456,7 +456,7 @@ public class PerUserPoolDataSource exten * @param username The user * @param value The value */ - public void setPerUserMinIdle(String username, Integer value) { + public void setPerUserMinIdle(final String username, final Integer value) { assertInitializationAllowed(); if (perUserMinIdle == null) { perUserMinIdle = new HashMap<>(); @@ -464,7 +464,7 @@ public class PerUserPoolDataSource exten perUserMinIdle.put(username, value); } - void setPerUserMinIdle(Map<String,Integer> userDefaultMinIdle) { + void setPerUserMinIdle(final Map<String,Integer> userDefaultMinIdle) { assertInitializationAllowed(); if (perUserMinIdle == null) { perUserMinIdle = new HashMap<>(); @@ -482,7 +482,7 @@ public class PerUserPoolDataSource exten * @param key The user * @return the tests count */ - public int getPerUserNumTestsPerEvictionRun(String key) { + public int getPerUserNumTestsPerEvictionRun(final String key) { Integer value = null; if (perUserNumTestsPerEvictionRun != null) { value = perUserNumTestsPerEvictionRun.get(key); @@ -500,8 +500,8 @@ public class PerUserPoolDataSource exten * @param username The user * @param value The value */ - public void setPerUserNumTestsPerEvictionRun(String username, - Integer value) { + public void setPerUserNumTestsPerEvictionRun(final String username, + final Integer value) { assertInitializationAllowed(); if (perUserNumTestsPerEvictionRun == null) { perUserNumTestsPerEvictionRun = new HashMap<>(); @@ -510,7 +510,7 @@ public class PerUserPoolDataSource exten } void setPerUserNumTestsPerEvictionRun( - Map<String,Integer> userDefaultNumTestsPerEvictionRun) { + final Map<String,Integer> userDefaultNumTestsPerEvictionRun) { assertInitializationAllowed(); if (perUserNumTestsPerEvictionRun == null) { perUserNumTestsPerEvictionRun = new HashMap<>(); @@ -528,7 +528,7 @@ public class PerUserPoolDataSource exten * @param key The user * @return the soft minimum idle time for eviction */ - public long getPerUserSoftMinEvictableIdleTimeMillis(String key) { + public long getPerUserSoftMinEvictableIdleTimeMillis(final String key) { Long value = null; if (perUserSoftMinEvictableIdleTimeMillis != null) { value = perUserSoftMinEvictableIdleTimeMillis.get(key); @@ -546,8 +546,8 @@ public class PerUserPoolDataSource exten * @param username The user * @param value The value */ - public void setPerUserSoftMinEvictableIdleTimeMillis(String username, - Long value) { + public void setPerUserSoftMinEvictableIdleTimeMillis(final String username, + final Long value) { assertInitializationAllowed(); if (perUserSoftMinEvictableIdleTimeMillis == null) { perUserSoftMinEvictableIdleTimeMillis = new HashMap<>(); @@ -556,7 +556,7 @@ public class PerUserPoolDataSource exten } void setPerUserSoftMinEvictableIdleTimeMillis( - Map<String,Long> userDefaultSoftMinEvictableIdleTimeMillis) { + final Map<String,Long> userDefaultSoftMinEvictableIdleTimeMillis) { assertInitializationAllowed(); if (perUserSoftMinEvictableIdleTimeMillis == null) { perUserSoftMinEvictableIdleTimeMillis = new HashMap<>(); @@ -574,7 +574,7 @@ public class PerUserPoolDataSource exten * @param key The user * @return <code>true</code> to test on create */ - public boolean getPerUserTestOnCreate(String key) { + public boolean getPerUserTestOnCreate(final String key) { Boolean value = null; if (perUserTestOnCreate != null) { value = perUserTestOnCreate.get(key); @@ -592,7 +592,7 @@ public class PerUserPoolDataSource exten * @param username The user * @param value The value */ - public void setPerUserTestOnCreate(String username, Boolean value) { + public void setPerUserTestOnCreate(final String username, final Boolean value) { assertInitializationAllowed(); if (perUserTestOnCreate == null) { perUserTestOnCreate = new HashMap<>(); @@ -600,7 +600,7 @@ public class PerUserPoolDataSource exten perUserTestOnCreate.put(username, value); } - void setPerUserTestOnCreate(Map<String,Boolean> userDefaultTestOnCreate) { + void setPerUserTestOnCreate(final Map<String,Boolean> userDefaultTestOnCreate) { assertInitializationAllowed(); if (perUserTestOnCreate == null) { perUserTestOnCreate = new HashMap<>(); @@ -618,7 +618,7 @@ public class PerUserPoolDataSource exten * @param key The user * @return <code>true</code> to test on borrow */ - public boolean getPerUserTestOnBorrow(String key) { + public boolean getPerUserTestOnBorrow(final String key) { Boolean value = null; if (perUserTestOnBorrow != null) { value = perUserTestOnBorrow.get(key); @@ -636,7 +636,7 @@ public class PerUserPoolDataSource exten * @param username The user * @param value The value */ - public void setPerUserTestOnBorrow(String username, Boolean value) { + public void setPerUserTestOnBorrow(final String username, final Boolean value) { assertInitializationAllowed(); if (perUserTestOnBorrow == null) { perUserTestOnBorrow = new HashMap<>(); @@ -644,7 +644,7 @@ public class PerUserPoolDataSource exten perUserTestOnBorrow.put(username, value); } - void setPerUserTestOnBorrow(Map<String,Boolean> userDefaultTestOnBorrow) { + void setPerUserTestOnBorrow(final Map<String,Boolean> userDefaultTestOnBorrow) { assertInitializationAllowed(); if (perUserTestOnBorrow == null) { perUserTestOnBorrow = new HashMap<>(); @@ -662,7 +662,7 @@ public class PerUserPoolDataSource exten * @param key The user * @return <code>true</code> to test on return */ - public boolean getPerUserTestOnReturn(String key) { + public boolean getPerUserTestOnReturn(final String key) { Boolean value = null; if (perUserTestOnReturn != null) { value = perUserTestOnReturn.get(key); @@ -680,7 +680,7 @@ public class PerUserPoolDataSource exten * @param username The user * @param value The value */ - public void setPerUserTestOnReturn(String username, Boolean value) { + public void setPerUserTestOnReturn(final String username, final Boolean value) { assertInitializationAllowed(); if (perUserTestOnReturn == null) { perUserTestOnReturn = new HashMap<>(); @@ -689,7 +689,7 @@ public class PerUserPoolDataSource exten } void setPerUserTestOnReturn( - Map<String,Boolean> userDefaultTestOnReturn) { + final Map<String,Boolean> userDefaultTestOnReturn) { assertInitializationAllowed(); if (perUserTestOnReturn == null) { perUserTestOnReturn = new HashMap<>(); @@ -707,7 +707,7 @@ public class PerUserPoolDataSource exten * @param key The user * @return <code>true</code> to test while idle */ - public boolean getPerUserTestWhileIdle(String key) { + public boolean getPerUserTestWhileIdle(final String key) { Boolean value = null; if (perUserTestWhileIdle != null) { value = perUserTestWhileIdle.get(key); @@ -725,7 +725,7 @@ public class PerUserPoolDataSource exten * @param username The user * @param value The value */ - public void setPerUserTestWhileIdle(String username, Boolean value) { + public void setPerUserTestWhileIdle(final String username, final Boolean value) { assertInitializationAllowed(); if (perUserTestWhileIdle == null) { perUserTestWhileIdle = new HashMap<>(); @@ -734,7 +734,7 @@ public class PerUserPoolDataSource exten } void setPerUserTestWhileIdle( - Map<String,Boolean> userDefaultTestWhileIdle) { + final Map<String,Boolean> userDefaultTestWhileIdle) { assertInitializationAllowed(); if (perUserTestWhileIdle == null) { perUserTestWhileIdle = new HashMap<>(); @@ -752,7 +752,7 @@ public class PerUserPoolDataSource exten * @param key The user * @return time between eviction runs */ - public long getPerUserTimeBetweenEvictionRunsMillis(String key) { + public long getPerUserTimeBetweenEvictionRunsMillis(final String key) { Long value = null; if (perUserTimeBetweenEvictionRunsMillis != null) { value = perUserTimeBetweenEvictionRunsMillis.get(key); @@ -770,8 +770,8 @@ public class PerUserPoolDataSource exten * @param username The user * @param value The value */ - public void setPerUserTimeBetweenEvictionRunsMillis(String username, - Long value) { + public void setPerUserTimeBetweenEvictionRunsMillis(final String username, + final Long value) { assertInitializationAllowed(); if (perUserTimeBetweenEvictionRunsMillis == null) { perUserTimeBetweenEvictionRunsMillis = new HashMap<>(); @@ -780,7 +780,7 @@ public class PerUserPoolDataSource exten } void setPerUserTimeBetweenEvictionRunsMillis( - Map<String,Long> userDefaultTimeBetweenEvictionRunsMillis ) { + final Map<String,Long> userDefaultTimeBetweenEvictionRunsMillis ) { assertInitializationAllowed(); if (perUserTimeBetweenEvictionRunsMillis == null) { perUserTimeBetweenEvictionRunsMillis = new HashMap<>(); @@ -798,7 +798,7 @@ public class PerUserPoolDataSource exten * @param key The user * @return <code>true</code> to commit automatically */ - public Boolean getPerUserDefaultAutoCommit(String key) { + public Boolean getPerUserDefaultAutoCommit(final String key) { Boolean value = null; if (perUserDefaultAutoCommit != null) { value = perUserDefaultAutoCommit.get(key); @@ -812,7 +812,7 @@ public class PerUserPoolDataSource exten * @param username The user * @param value The value */ - public void setPerUserDefaultAutoCommit(String username, Boolean value) { + public void setPerUserDefaultAutoCommit(final String username, final Boolean value) { assertInitializationAllowed(); if (perUserDefaultAutoCommit == null) { perUserDefaultAutoCommit = new HashMap<>(); @@ -820,7 +820,7 @@ public class PerUserPoolDataSource exten perUserDefaultAutoCommit.put(username, value); } - void setPerUserDefaultAutoCommit(Map<String,Boolean> userDefaultAutoCommit) { + void setPerUserDefaultAutoCommit(final Map<String,Boolean> userDefaultAutoCommit) { assertInitializationAllowed(); if (perUserDefaultAutoCommit == null) { perUserDefaultAutoCommit = new HashMap<>(); @@ -837,7 +837,7 @@ public class PerUserPoolDataSource exten * @param key The user * @return <code>true</code> is read only by default */ - public Boolean getPerUserDefaultReadOnly(String key) { + public Boolean getPerUserDefaultReadOnly(final String key) { Boolean value = null; if (perUserDefaultReadOnly != null) { value = perUserDefaultReadOnly.get(key); @@ -851,7 +851,7 @@ public class PerUserPoolDataSource exten * @param username The user * @param value The value */ - public void setPerUserDefaultReadOnly(String username, Boolean value) { + public void setPerUserDefaultReadOnly(final String username, final Boolean value) { assertInitializationAllowed(); if (perUserDefaultReadOnly == null) { perUserDefaultReadOnly = new HashMap<>(); @@ -859,7 +859,7 @@ public class PerUserPoolDataSource exten perUserDefaultReadOnly.put(username, value); } - void setPerUserDefaultReadOnly(Map<String,Boolean> userDefaultReadOnly) { + void setPerUserDefaultReadOnly(final Map<String,Boolean> userDefaultReadOnly) { assertInitializationAllowed(); if (perUserDefaultReadOnly == null) { perUserDefaultReadOnly = new HashMap<>(); @@ -876,7 +876,7 @@ public class PerUserPoolDataSource exten * @param key The user * @return the default transaction isolation */ - public Integer getPerUserDefaultTransactionIsolation(String key) { + public Integer getPerUserDefaultTransactionIsolation(final String key) { Integer value = null; if (perUserDefaultTransactionIsolation != null) { value = perUserDefaultTransactionIsolation.get(key); @@ -890,8 +890,8 @@ public class PerUserPoolDataSource exten * @param username The user * @param value The value */ - public void setPerUserDefaultTransactionIsolation(String username, - Integer value) { + public void setPerUserDefaultTransactionIsolation(final String username, + final Integer value) { assertInitializationAllowed(); if (perUserDefaultTransactionIsolation == null) { perUserDefaultTransactionIsolation = new HashMap<>(); @@ -900,7 +900,7 @@ public class PerUserPoolDataSource exten } void setPerUserDefaultTransactionIsolation( - Map<String,Integer> userDefaultTransactionIsolation) { + final Map<String,Integer> userDefaultTransactionIsolation) { assertInitializationAllowed(); if (perUserDefaultTransactionIsolation == null) { perUserDefaultTransactionIsolation = new HashMap<>(); @@ -925,8 +925,8 @@ public class PerUserPoolDataSource exten * @param username The user * @return the number of active connections in the pool for a given user. */ - public int getNumActive(String username) { - ObjectPool<PooledConnectionAndInfo> pool = + public int getNumActive(final String username) { + final ObjectPool<PooledConnectionAndInfo> pool = getPool(getPoolKey(username)); return pool == null ? 0 : pool.getNumActive(); } @@ -942,8 +942,8 @@ public class PerUserPoolDataSource exten * @param username The user * @return the number of idle connections in the pool for a given user. */ - public int getNumIdle(String username) { - ObjectPool<PooledConnectionAndInfo> pool = + public int getNumIdle(final String username) { + final ObjectPool<PooledConnectionAndInfo> pool = getPool(getPoolKey(username)); return pool == null ? 0 : pool.getNumIdle(); } @@ -954,7 +954,7 @@ public class PerUserPoolDataSource exten @Override protected PooledConnectionAndInfo - getPooledConnectionAndInfo(String username, String password) + getPooledConnectionAndInfo(final String username, final String password) throws SQLException { final PoolKey key = getPoolKey(username); @@ -966,7 +966,7 @@ public class PerUserPoolDataSource exten try { registerPool(username, password); manager = managers.get(key); - } catch (NamingException e) { + } catch (final NamingException e) { throw new SQLException("RegisterPool failed", e); } } @@ -977,15 +977,15 @@ public class PerUserPoolDataSource exten try { info = pool.borrowObject(); } - catch (NoSuchElementException ex) { + catch (final NoSuchElementException ex) { throw new SQLException( "Could not retrieve connection info from pool", ex); } - catch (Exception e) { + catch (final Exception e) { // See if failure is due to CPDSConnectionFactory authentication failure try { testCPDS(username, password); - } catch (Exception ex) { + } catch (final Exception ex) { throw new SQLException( "Could not retrieve connection info from pool", ex); } @@ -997,12 +997,12 @@ public class PerUserPoolDataSource exten try { registerPool(username, password); pool = getPool(key); - } catch (NamingException ne) { + } catch (final NamingException ne) { throw new SQLException("RegisterPool failed", ne); } try { info = pool.borrowObject(); - } catch (Exception ex) { + } catch (final Exception ex) { throw new SQLException( "Could not retrieve connection info from pool", ex); } @@ -1011,11 +1011,11 @@ public class PerUserPoolDataSource exten } @Override - protected void setupDefaults(Connection con, String username) + protected void setupDefaults(final Connection con, final String username) throws SQLException { Boolean defaultAutoCommit = isDefaultAutoCommit(); if (username != null) { - Boolean userMax = getPerUserDefaultAutoCommit(username); + final Boolean userMax = getPerUserDefaultAutoCommit(username); if (userMax != null) { defaultAutoCommit = userMax; } @@ -1023,7 +1023,7 @@ public class PerUserPoolDataSource exten Boolean defaultReadOnly = isDefaultReadOnly(); if (username != null) { - Boolean userMax = getPerUserDefaultReadOnly(username); + final Boolean userMax = getPerUserDefaultReadOnly(username); if (userMax != null) { defaultReadOnly = userMax; } @@ -1031,7 +1031,7 @@ public class PerUserPoolDataSource exten int defaultTransactionIsolation = getDefaultTransactionIsolation(); if (username != null) { - Integer userMax = getPerUserDefaultTransactionIsolation(username); + final Integer userMax = getPerUserDefaultTransactionIsolation(username); if (userMax != null) { defaultTransactionIsolation = userMax.intValue(); } @@ -1053,7 +1053,7 @@ public class PerUserPoolDataSource exten } @Override - protected PooledConnectionManager getConnectionManager(UserPassKey upkey) { + protected PooledConnectionManager getConnectionManager(final UserPassKey upkey) { return managers.get(getPoolKey(upkey.getUsername())); } @@ -1063,7 +1063,7 @@ public class PerUserPoolDataSource exten */ @Override public Reference getReference() throws NamingException { - Reference ref = new Reference(getClass().getName(), + final Reference ref = new Reference(getClass().getName(), PerUserPoolDataSourceFactory.class.getName(), null); ref.add(new StringRefAddr("instanceKey", getInstanceKey())); return ref; @@ -1075,25 +1075,25 @@ public class PerUserPoolDataSource exten * @param username User name * @return the pool key */ - private PoolKey getPoolKey(String username) { + private PoolKey getPoolKey(final String username) { return new PoolKey(getDataSourceName(), username); } - private synchronized void registerPool(String username, String password) + private synchronized void registerPool(final String username, final String password) throws NamingException, SQLException { - ConnectionPoolDataSource cpds = testCPDS(username, password); + final ConnectionPoolDataSource cpds = testCPDS(username, password); // Set up the factory we will use (passing the pool associates // the factory with the pool, so we do not have to do so // explicitly) - CPDSConnectionFactory factory = new CPDSConnectionFactory(cpds, + final CPDSConnectionFactory factory = new CPDSConnectionFactory(cpds, getValidationQuery(), getValidationQueryTimeout(), isRollbackAfterValidation(), username, password); factory.setMaxConnLifetimeMillis(getMaxConnLifetimeMillis()); // Create an object pool to contain our PooledConnections - GenericObjectPool<PooledConnectionAndInfo> pool = + final GenericObjectPool<PooledConnectionAndInfo> pool = new GenericObjectPool<>(factory); factory.setPool(pool); pool.setBlockWhenExhausted(getPerUserBlockWhenExhausted(username)); @@ -1119,7 +1119,7 @@ public class PerUserPoolDataSource exten pool.setSwallowedExceptionListener(new SwallowedExceptionLogger(log)); - Object old = managers.put(getPoolKey(username), factory); + final Object old = managers.put(getPoolKey(username), factory); if (old != null) { throw new IllegalStateException("Pool already contains an entry for this user/password: " + username); } @@ -1132,17 +1132,17 @@ public class PerUserPoolDataSource exten * @exception IOException if an error occurs * @exception ClassNotFoundException if an error occurs */ - private void readObject(ObjectInputStream in) + private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { try { in.defaultReadObject(); - PerUserPoolDataSource oldDS = (PerUserPoolDataSource) + final PerUserPoolDataSource oldDS = (PerUserPoolDataSource) new PerUserPoolDataSourceFactory() .getObjectInstance(getReference(), null, null, null); this.managers = oldDS.managers; } - catch (NamingException e) + catch (final NamingException e) { throw new IOException("NamingException: " + e); } @@ -1155,8 +1155,8 @@ public class PerUserPoolDataSource exten * @return the GenericObjectPool pooling connections for the username and datasource * specified by the PoolKey */ - private ObjectPool<PooledConnectionAndInfo> getPool(PoolKey key) { - CPDSConnectionFactory mgr = (CPDSConnectionFactory) managers.get(key); + private ObjectPool<PooledConnectionAndInfo> getPool(final PoolKey key) { + final CPDSConnectionFactory mgr = (CPDSConnectionFactory) managers.get(key); return mgr == null ? null : mgr.getPool(); } }
Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/PerUserPoolDataSourceFactory.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/PerUserPoolDataSourceFactory.java?rev=1743719&r1=1743718&r2=1743719&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/PerUserPoolDataSourceFactory.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/PerUserPoolDataSourceFactory.java Fri May 13 18:49:32 2016 @@ -35,15 +35,15 @@ public class PerUserPoolDataSourceFactor PerUserPoolDataSource.class.getName(); @Override - protected boolean isCorrectClass(String className) { + protected boolean isCorrectClass(final String className) { return PER_USER_POOL_CLASSNAME.equals(className); } @SuppressWarnings("unchecked") // Avoid warnings on deserialization @Override - protected InstanceKeyDataSource getNewInstance(Reference ref) + protected InstanceKeyDataSource getNewInstance(final Reference ref) throws IOException, ClassNotFoundException { - PerUserPoolDataSource pupds = new PerUserPoolDataSource(); + final PerUserPoolDataSource pupds = new PerUserPoolDataSource(); RefAddr ra = ref.get("defaultMaxTotal"); if (ra != null && ra.getContent() != null) { pupds.setDefaultMaxTotal( @@ -64,42 +64,42 @@ public class PerUserPoolDataSourceFactor ra = ref.get("perUserDefaultAutoCommit"); if (ra != null && ra.getContent() != null) { - byte[] serialized = (byte[]) ra.getContent(); + final byte[] serialized = (byte[]) ra.getContent(); pupds.setPerUserDefaultAutoCommit( (Map<String,Boolean>) deserialize(serialized)); } ra = ref.get("perUserDefaultTransactionIsolation"); if (ra != null && ra.getContent() != null) { - byte[] serialized = (byte[]) ra.getContent(); + final byte[] serialized = (byte[]) ra.getContent(); pupds.setPerUserDefaultTransactionIsolation( (Map<String,Integer>) deserialize(serialized)); } ra = ref.get("perUserMaxTotal"); if (ra != null && ra.getContent() != null) { - byte[] serialized = (byte[]) ra.getContent(); + final byte[] serialized = (byte[]) ra.getContent(); pupds.setPerUserMaxTotal( (Map<String,Integer>) deserialize(serialized)); } ra = ref.get("perUserMaxIdle"); if (ra != null && ra.getContent() != null) { - byte[] serialized = (byte[]) ra.getContent(); + final byte[] serialized = (byte[]) ra.getContent(); pupds.setPerUserMaxIdle( (Map<String,Integer>) deserialize(serialized)); } ra = ref.get("perUserMaxWaitMillis"); if (ra != null && ra.getContent() != null) { - byte[] serialized = (byte[]) ra.getContent(); + final byte[] serialized = (byte[]) ra.getContent(); pupds.setPerUserMaxWaitMillis( (Map<String,Long>) deserialize(serialized)); } ra = ref.get("perUserDefaultReadOnly"); if (ra != null && ra.getContent() != null) { - byte[] serialized = (byte[]) ra.getContent(); + final byte[] serialized = (byte[]) ra.getContent(); pupds.setPerUserDefaultReadOnly( (Map<String,Boolean>) deserialize(serialized)); } Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/PoolKey.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/PoolKey.java?rev=1743719&r1=1743718&r2=1743719&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/PoolKey.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/PoolKey.java Fri May 13 18:49:32 2016 @@ -28,15 +28,15 @@ class PoolKey implements Serializable { private final String datasourceName; private final String username; - PoolKey(String datasourceName, String username) { + PoolKey(final String datasourceName, final String username) { this.datasourceName = datasourceName; this.username = username; } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (obj instanceof PoolKey) { - PoolKey pk = (PoolKey)obj; + final PoolKey pk = (PoolKey)obj; return (null == datasourceName ? null == pk.datasourceName : datasourceName.equals(pk.datasourceName)) && (null == username ? null == pk.username : username.equals(pk.username)); } @@ -57,7 +57,7 @@ class PoolKey implements Serializable { @Override public String toString() { - StringBuffer sb = new StringBuffer(50); + final StringBuffer sb = new StringBuffer(50); sb.append("PoolKey("); sb.append(username).append(", ").append(datasourceName); sb.append(')'); Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/PooledConnectionAndInfo.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/PooledConnectionAndInfo.java?rev=1743719&r1=1743718&r2=1743719&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/PooledConnectionAndInfo.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/PooledConnectionAndInfo.java Fri May 13 18:49:32 2016 @@ -31,7 +31,7 @@ final class PooledConnectionAndInfo { private final String username; private final UserPassKey upkey; - PooledConnectionAndInfo(PooledConnection pc, String username, String password) { + PooledConnectionAndInfo(final PooledConnection pc, final String username, final String password) { this.pooledConnection = pc; this.username = username; this.password = password; Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/SharedPoolDataSource.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/SharedPoolDataSource.java?rev=1743719&r1=1743718&r2=1743719&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/SharedPoolDataSource.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/SharedPoolDataSource.java Fri May 13 18:49:32 2016 @@ -91,7 +91,7 @@ public class SharedPoolDataSource extend * Set {@link GenericKeyedObjectPool#getMaxTotal()} for this pool. * @param maxTotal The max total value */ - public void setMaxTotal(int maxTotal) { + public void setMaxTotal(final int maxTotal) { assertInitializationAllowed(); this.maxTotal = maxTotal; } @@ -119,14 +119,14 @@ public class SharedPoolDataSource extend @Override protected PooledConnectionAndInfo - getPooledConnectionAndInfo(String username, String password) + getPooledConnectionAndInfo(final String username, final String password) throws SQLException { synchronized(this) { if (pool == null) { try { registerPool(username, password); - } catch (NamingException e) { + } catch (final NamingException e) { throw new SQLException("RegisterPool failed", e); } } @@ -134,12 +134,12 @@ public class SharedPoolDataSource extend PooledConnectionAndInfo info = null; - UserPassKey key = new UserPassKey(username, password); + final UserPassKey key = new UserPassKey(username, password); try { info = pool.borrowObject(key); } - catch (Exception e) { + catch (final Exception e) { throw new SQLException( "Could not retrieve connection info from pool", e); } @@ -147,7 +147,7 @@ public class SharedPoolDataSource extend } @Override - protected PooledConnectionManager getConnectionManager(UserPassKey upkey) { + protected PooledConnectionManager getConnectionManager(final UserPassKey upkey) { return factory; } @@ -157,23 +157,23 @@ public class SharedPoolDataSource extend */ @Override public Reference getReference() throws NamingException { - Reference ref = new Reference(getClass().getName(), + final Reference ref = new Reference(getClass().getName(), SharedPoolDataSourceFactory.class.getName(), null); ref.add(new StringRefAddr("instanceKey", getInstanceKey())); return ref; } - private void registerPool(String username, String password) + private void registerPool(final String username, final String password) throws NamingException, SQLException { - ConnectionPoolDataSource cpds = testCPDS(username, password); + final ConnectionPoolDataSource cpds = testCPDS(username, password); // Create an object pool to contain our PooledConnections factory = new KeyedCPDSConnectionFactory(cpds, getValidationQuery(), getValidationQueryTimeout(), isRollbackAfterValidation()); factory.setMaxConnLifetimeMillis(getMaxConnLifetimeMillis()); - GenericKeyedObjectPoolConfig config = + final GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig(); config.setBlockWhenExhausted(getDefaultBlockWhenExhausted()); config.setEvictionPolicyClassName(getDefaultEvictionPolicyClassName()); @@ -195,26 +195,26 @@ public class SharedPoolDataSource extend config.setTimeBetweenEvictionRunsMillis( getDefaultTimeBetweenEvictionRunsMillis()); - KeyedObjectPool<UserPassKey,PooledConnectionAndInfo> tmpPool = + final KeyedObjectPool<UserPassKey,PooledConnectionAndInfo> tmpPool = new GenericKeyedObjectPool<>(factory, config); factory.setPool(tmpPool); pool = tmpPool; } @Override - protected void setupDefaults(Connection con, String username) throws SQLException { - Boolean defaultAutoCommit = isDefaultAutoCommit(); + protected void setupDefaults(final Connection con, final String username) throws SQLException { + final Boolean defaultAutoCommit = isDefaultAutoCommit(); if (defaultAutoCommit != null && con.getAutoCommit() != defaultAutoCommit.booleanValue()) { con.setAutoCommit(defaultAutoCommit.booleanValue()); } - int defaultTransactionIsolation = getDefaultTransactionIsolation(); + final int defaultTransactionIsolation = getDefaultTransactionIsolation(); if (defaultTransactionIsolation != UNKNOWN_TRANSACTIONISOLATION) { con.setTransactionIsolation(defaultTransactionIsolation); } - Boolean defaultReadOnly = isDefaultReadOnly(); + final Boolean defaultReadOnly = isDefaultReadOnly(); if (defaultReadOnly != null && con.isReadOnly() != defaultReadOnly.booleanValue()) { con.setReadOnly(defaultReadOnly.booleanValue()); @@ -228,17 +228,17 @@ public class SharedPoolDataSource extend * @exception IOException if an error occurs * @exception ClassNotFoundException if an error occurs */ - private void readObject(ObjectInputStream in) + private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { try { in.defaultReadObject(); - SharedPoolDataSource oldDS = (SharedPoolDataSource) + final SharedPoolDataSource oldDS = (SharedPoolDataSource) new SharedPoolDataSourceFactory() .getObjectInstance(getReference(), null, null, null); this.pool = oldDS.pool; } - catch (NamingException e) + catch (final NamingException e) { throw new IOException("NamingException: " + e); } Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/SharedPoolDataSourceFactory.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/SharedPoolDataSourceFactory.java?rev=1743719&r1=1743718&r2=1743719&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/SharedPoolDataSourceFactory.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/SharedPoolDataSourceFactory.java Fri May 13 18:49:32 2016 @@ -31,14 +31,14 @@ public class SharedPoolDataSourceFactory SharedPoolDataSource.class.getName(); @Override - protected boolean isCorrectClass(String className) { + protected boolean isCorrectClass(final String className) { return SHARED_POOL_CLASSNAME.equals(className); } @Override - protected InstanceKeyDataSource getNewInstance(Reference ref) { - SharedPoolDataSource spds = new SharedPoolDataSource(); - RefAddr ra = ref.get("maxTotal"); + protected InstanceKeyDataSource getNewInstance(final Reference ref) { + final SharedPoolDataSource spds = new SharedPoolDataSource(); + final RefAddr ra = ref.get("maxTotal"); if (ra != null && ra.getContent() != null) { spds.setMaxTotal( Integer.parseInt(ra.getContent().toString())); Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/UserPassKey.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/UserPassKey.java?rev=1743719&r1=1743718&r2=1743719&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/UserPassKey.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/UserPassKey.java Fri May 13 18:49:32 2016 @@ -35,7 +35,7 @@ class UserPassKey implements Serializabl private final String password; private final String username; - UserPassKey(String username, String password) { + UserPassKey(final String username, final String password) { this.username = username; this.password = password; } @@ -64,7 +64,7 @@ class UserPassKey implements Serializabl * @see java.lang.Object#equals(java.lang.Object) */ @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (obj == null) { return false; } @@ -77,7 +77,7 @@ class UserPassKey implements Serializabl return false; } - UserPassKey key = (UserPassKey) obj; + final UserPassKey key = (UserPassKey) obj; return this.username == null ? key.username == null : @@ -95,7 +95,7 @@ class UserPassKey implements Serializabl @Override public String toString() { - StringBuffer sb = new StringBuffer(50); + final StringBuffer sb = new StringBuffer(50); sb.append("UserPassKey("); sb.append(username).append(", ").append(password).append(')'); return sb.toString(); Modified: tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml?rev=1743719&r1=1743718&r2=1743719&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml Fri May 13 18:49:32 2016 @@ -58,6 +58,14 @@ </fix> </changelog> </subsection> + <subsection name="Other"> + <changelog> + <update> + Update the internal fork of Commons DBCP 2 to r1743696 (2.1.1 plus + additional fixes). (markt) + </update> + </changelog> + </subsection> </section> <section name="Tomcat 8.5.2" rtext="release in progress"> <subsection name="Catalina"> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
