Skip to content

Commit

Permalink
fixed typo
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Oct 3, 2013
1 parent aaedab6 commit 7b1d6bf
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/main/java/com/alibaba/druid/pool/DruidDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -895,37 +895,37 @@ public PooledConnection getPooledConnection(String user, String password) throws

public DruidPooledConnection getConnectionDirect(long maxWaitMillis) throws SQLException {
for (;;) {
DruidPooledConnection poolalbeConnection = getConnectionInternal(maxWaitMillis);
DruidPooledConnection poolableConnection = getConnectionInternal(maxWaitMillis);

if (isTestOnBorrow()) {
boolean validate = testConnectionInternal(poolalbeConnection.getConnection());
boolean validate = testConnectionInternal(poolableConnection.getConnection());
if (!validate) {
if (LOG.isDebugEnabled()) {
LOG.debug("skip not validate connection.");
}

Connection realConnection = poolalbeConnection.getConnection();
Connection realConnection = poolableConnection.getConnection();
discardConnection(realConnection);
continue;
}
} else {
Connection realConnection = poolalbeConnection.getConnection();
Connection realConnection = poolableConnection.getConnection();
if (realConnection.isClosed()) {
discardConnection(null); // 传入null,避免重复关闭
continue;
}

if (isTestWhileIdle()) {
final long currentTimeMillis = System.currentTimeMillis();
final long lastActiveTimeMillis = poolalbeConnection.getConnectionHolder().getLastActiveTimeMillis();
final long lastActiveTimeMillis = poolableConnection.getConnectionHolder().getLastActiveTimeMillis();
final long idleMillis = currentTimeMillis - lastActiveTimeMillis;
long timeBetweenEvictionRunsMillis = this.getTimeBetweenEvictionRunsMillis();
if (timeBetweenEvictionRunsMillis <= 0) {
timeBetweenEvictionRunsMillis = DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS;
}

if (idleMillis >= timeBetweenEvictionRunsMillis) {
boolean validate = testConnectionInternal(poolalbeConnection.getConnection());
boolean validate = testConnectionInternal(poolableConnection.getConnection());
if (!validate) {
if (LOG.isDebugEnabled()) {
LOG.debug("skip not validate connection.");
Expand All @@ -940,20 +940,20 @@ public DruidPooledConnection getConnectionDirect(long maxWaitMillis) throws SQLE

if (isRemoveAbandoned()) {
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
poolalbeConnection.setConnectStackTrace(stackTrace);
poolalbeConnection.setConnectedTimeNano();
poolalbeConnection.setTraceEnable(true);
poolableConnection.setConnectStackTrace(stackTrace);
poolableConnection.setConnectedTimeNano();
poolableConnection.setTraceEnable(true);

synchronized (activeConnections) {
activeConnections.put(poolalbeConnection, PRESENT);
activeConnections.put(poolableConnection, PRESENT);
}
}

if (!this.isDefaultAutoCommit()) {
poolalbeConnection.setAutoCommit(false);
poolableConnection.setAutoCommit(false);
}

return poolalbeConnection;
return poolableConnection;
}
}

Expand Down

0 comments on commit 7b1d6bf

Please sign in to comment.