This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-dbcp.git
The following commit(s) were added to refs/heads/master by this push: new 406aff1 Use the scale in the var name. 406aff1 is described below commit 406aff14b5eb65b26e86a143fa69b871e49d88ff Author: Gary Gregory <gardgreg...@gmail.com> AuthorDate: Tue Feb 2 17:32:43 2021 -0500 Use the scale in the var name. --- .../commons/dbcp2/PoolableConnectionFactory.java | 6 ++--- .../dbcp2/datasources/CPDSConnectionFactory.java | 6 ++--- .../datasources/KeyedCPDSConnectionFactory.java | 6 ++--- .../apache/commons/dbcp2/TestConnectionPool.java | 28 +++++++++++----------- .../datasources/TestSharedPoolDataSource.java | 6 ++--- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java b/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java index 5598f13..276b98d 100644 --- a/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java +++ b/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java @@ -659,10 +659,10 @@ public class PoolableConnectionFactory implements PooledObjectFactory<PoolableCo private void validateLifetime(final PooledObject<PoolableConnection> p) throws Exception { if (maxConnLifetimeMillis > 0) { - final long lifetime = System.currentTimeMillis() - p.getCreateTime(); - if (lifetime > maxConnLifetimeMillis) { + final long lifetimeMillis = System.currentTimeMillis() - p.getCreateTime(); + if (lifetimeMillis > maxConnLifetimeMillis) { throw new LifetimeExceededException(Utils.getMessage("connectionFactory.lifetimeExceeded", - lifetime, maxConnLifetimeMillis)); + lifetimeMillis, maxConnLifetimeMillis)); } } } diff --git a/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java b/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java index 49e22a7..29df4a0 100644 --- a/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java +++ b/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java @@ -384,9 +384,9 @@ class CPDSConnectionFactory private void validateLifetime(final PooledObject<PooledConnectionAndInfo> p) throws Exception { if (maxConnLifetimeMillis > 0) { - final long lifetime = System.currentTimeMillis() - p.getCreateTime(); - if (lifetime > maxConnLifetimeMillis) { - throw new Exception(Utils.getMessage("connectionFactory.lifetimeExceeded", lifetime, + final long lifetimeMillis = System.currentTimeMillis() - p.getCreateTime(); + if (lifetimeMillis > maxConnLifetimeMillis) { + throw new Exception(Utils.getMessage("connectionFactory.lifetimeExceeded", lifetimeMillis, maxConnLifetimeMillis)); } } diff --git a/src/main/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java b/src/main/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java index 4f3de4b..5976253 100644 --- a/src/main/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java +++ b/src/main/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java @@ -334,9 +334,9 @@ class KeyedCPDSConnectionFactory implements KeyedPooledObjectFactory<UserPassKey private void validateLifetime(final PooledObject<PooledConnectionAndInfo> p) throws Exception { if (maxConnLifetimeMillis > 0) { - final long lifetime = System.currentTimeMillis() - p.getCreateTime(); - if (lifetime > maxConnLifetimeMillis) { - throw new Exception(Utils.getMessage("connectionFactory.lifetimeExceeded", lifetime, + final long lifetimeMillis = System.currentTimeMillis() - p.getCreateTime(); + if (lifetimeMillis > maxConnLifetimeMillis) { + throw new Exception(Utils.getMessage("connectionFactory.lifetimeExceeded", lifetimeMillis, maxConnLifetimeMillis)); } } diff --git a/src/test/java/org/apache/commons/dbcp2/TestConnectionPool.java b/src/test/java/org/apache/commons/dbcp2/TestConnectionPool.java index 2d80486..c16c34d 100644 --- a/src/test/java/org/apache/commons/dbcp2/TestConnectionPool.java +++ b/src/test/java/org/apache/commons/dbcp2/TestConnectionPool.java @@ -752,7 +752,7 @@ public abstract class TestConnectionPool { protected void multipleThreads(final int holdTime, final boolean expectError, final boolean loopOnce, final long maxWaitMillis, final int numStatements, final int numThreads, final long duration) throws Exception { - final long startTime = timeStamp(); + final long startTimeMillis = timeStampMillis(); final PoolTest[] pts = new PoolTest[numThreads]; // Catch Exception so we can stop all threads if one fails final ThreadGroup threadGroup = new ThreadGroup("foo") { @@ -808,8 +808,8 @@ public abstract class TestConnectionPool { } } - final long time = timeStamp() - startTime; - System.out.println("Multithread test time = " + time + final long timeMillis = timeStampMillis() - startTimeMillis; + System.out.println("Multithread test time = " + timeMillis + " ms. Threads: " + pts.length + ". Loops: " + loops + ". Hold time: " + holdTime @@ -821,7 +821,7 @@ public abstract class TestConnectionPool { ); if (expectError) { if (DISPLAY_THREAD_DETAILS || (pts.length/2 != failed)){ - final long offset = pts[0].created - 1000; // To reduce size of output numbers, but ensure they have 4 digits + final long offset = pts[0].createdMillis - 1000; // To reduce size of output numbers, but ensure they have 4 digits System.out.println("Offset: "+offset); for (int i = 0; i < pts.length; i++) { final PoolTest pt = pts[i]; @@ -829,7 +829,7 @@ public abstract class TestConnectionPool { "Pre: " + (pt.preconnected-offset) // First, so can sort on this easily + ". Post: " + (pt.postconnected != 0 ? Long.toString(pt.postconnected-offset): "-") + ". Hash: " + pt.connHash - + ". Startup: " + (pt.started-pt.created) + + ". Startup: " + (pt.started-pt.createdMillis) + ". getConn(): " + (pt.connected != 0 ? Long.toString(pt.connected-pt.preconnected) : "-") + ". Runtime: " + (pt.ended-pt.started) + ". IDX: " + i @@ -846,7 +846,7 @@ public abstract class TestConnectionPool { // Perform initial sanity check: assertTrue(failed > 0, "Expected some of the threads to fail"); // Assume that threads that did not run would have timed out. - assertEquals(pts.length/2, failed+didNotRun, "WARNING: Expected half the threads to fail"); + assertEquals(pts.length / 2, failed + didNotRun, "WARNING: Expected half the threads to fail"); } else { assertEquals(0, failed, "Did not expect any threads to fail"); } @@ -874,7 +874,7 @@ public abstract class TestConnectionPool { private final Random random = new Random(); // Debug for DBCP-318 - private final long created; // When object was created + private final long createdMillis; // When object was created private long started; // when thread started private long ended; // when thread ended private long preconnected; // just before connect @@ -904,7 +904,7 @@ public abstract class TestConnectionPool { thread = new Thread(threadGroup, this, "Thread+" + currentThreadCount++); thread.setDaemon(false); - created = timeStamp(); + createdMillis = timeStampMillis(); this.numStatements = numStatements; } @@ -914,15 +914,15 @@ public abstract class TestConnectionPool { @Override public void run() { - started = timeStamp(); + started = timeStampMillis(); try { while (isRun) { loops++; state = "Getting Connection"; - preconnected = timeStamp(); + preconnected = timeStampMillis(); final Connection conn = getConnection(); connHash = System.identityHashCode(((DelegatingConnection<?>)conn).getInnermostDelegate()); - connected = timeStamp(); + connected = timeStampMillis(); state = "Using Connection"; assertNotNull(conn); final String sql = numStatements == 1 ? "select * from dual" : "select count " + random.nextInt(numStatements - 1); @@ -940,7 +940,7 @@ public abstract class TestConnectionPool { stmt.close(); state = "Closing Connection"; conn.close(); - postconnected = timeStamp(); + postconnected = timeStampMillis(); state = "Closed"; if (loopOnce){ break; // Or could set isRun=false @@ -953,7 +953,7 @@ public abstract class TestConnectionPool { throw new RuntimeException(); } } finally { - ended = timeStamp(); + ended = timeStampMillis(); } } @@ -966,7 +966,7 @@ public abstract class TestConnectionPool { } } - long timeStamp() { + long timeStampMillis() { return System.currentTimeMillis();// JVM 1.5+ System.nanoTime() / 1000000; } } diff --git a/src/test/java/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java b/src/test/java/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java index f64ae20..4d18fd8 100644 --- a/src/test/java/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java +++ b/src/test/java/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java @@ -325,7 +325,7 @@ public class TestSharedPoolDataSource extends TestConnectionPool { assertTrue(c[i] != null); } - final long start = System.currentTimeMillis(); + final long startMillis = System.currentTimeMillis(); // Run a thread test with minimal hold time // All threads should end after maxWaitMillis - DBCP-291 @@ -343,12 +343,12 @@ public class TestSharedPoolDataSource extends TestConnectionPool { } - final long end = System.currentTimeMillis(); + final long endMillis = System.currentTimeMillis(); // System.out.println("testMaxWaitMillis took " + (end - start) + " ms. maxWaitMillis: " + maxWaitMillis); // Threads should time out in parallel - allow double that to be safe - assertTrue(end-start < 2 * maxWaitMillis); + assertTrue(endMillis - startMillis < 2 * maxWaitMillis); // Put all the connections back in the pool for (final Connection element : c) {