From 028996b508d049b39323c9658a4f06dec3b49ec0 Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Wed, 8 Oct 2014 17:13:12 +0900 Subject: [PATCH] Minor optimizations. --- .../java/com/zaxxer/hikari/pool/PoolBagEntry.java | 13 +++++-------- .../java/com/zaxxer/hikari/pool/PoolBagEntry.java | 12 +++++------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/hikaricp-java6/src/main/java/com/zaxxer/hikari/pool/PoolBagEntry.java b/hikaricp-java6/src/main/java/com/zaxxer/hikari/pool/PoolBagEntry.java index 25e258e8..e6ffbee3 100644 --- a/hikaricp-java6/src/main/java/com/zaxxer/hikari/pool/PoolBagEntry.java +++ b/hikaricp-java6/src/main/java/com/zaxxer/hikari/pool/PoolBagEntry.java @@ -34,19 +34,16 @@ public final class PoolBagEntry extends BagEntry PoolBagEntry(final Connection connection, long maxLifetime) { this.connection = connection; - expirationTime = (maxLifetime > 0 ? System.currentTimeMillis() + maxLifetime : Long.MAX_VALUE); lastAccess = System.currentTimeMillis(); + expirationTime = (maxLifetime > 0 ? lastAccess + maxLifetime : Long.MAX_VALUE); } @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("Connection: ").append(connection).append('\n'); - sb.append("Expiration: ").append(expirationTime).append('\n'); - sb.append("Last access: ").append(lastAccess).append('\n'); - sb.append("Last open: ").append(lastOpenTime); - return sb.toString(); + return "Connection......" + connection + "\n" + + " Expiration...." + expirationTime + "\n" + + " Last access.." + lastAccess + "\n" + + " Last open....." + lastOpenTime + "\n"; } } - diff --git a/hikaricp/src/main/java/com/zaxxer/hikari/pool/PoolBagEntry.java b/hikaricp/src/main/java/com/zaxxer/hikari/pool/PoolBagEntry.java index 25e258e8..c00c845f 100644 --- a/hikaricp/src/main/java/com/zaxxer/hikari/pool/PoolBagEntry.java +++ b/hikaricp/src/main/java/com/zaxxer/hikari/pool/PoolBagEntry.java @@ -34,19 +34,17 @@ public final class PoolBagEntry extends BagEntry PoolBagEntry(final Connection connection, long maxLifetime) { this.connection = connection; - expirationTime = (maxLifetime > 0 ? System.currentTimeMillis() + maxLifetime : Long.MAX_VALUE); lastAccess = System.currentTimeMillis(); + expirationTime = (maxLifetime > 0 ? lastAccess + maxLifetime : Long.MAX_VALUE); } @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("Connection: ").append(connection).append('\n'); - sb.append("Expiration: ").append(expirationTime).append('\n'); - sb.append("Last access: ").append(lastAccess).append('\n'); - sb.append("Last open: ").append(lastOpenTime); - return sb.toString(); + return "Connection......" + connection + "\n" + + " Expiration...." + expirationTime + "\n" + + " Last access.." + lastAccess + "\n" + + " Last open....." + lastOpenTime + "\n"; } }