Skip to content

Commit ddadab8

Browse files
author
lucaijun
committed
AJ-554: fix connection count
1 parent 54958c4 commit ddadab8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/com/xxdb/SimpleDBConnectionPool.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,26 @@ else if (Objects.nonNull(connectionPool)) {
5858
}
5959

6060
public int getActiveConnectionsCount() {
61+
if (Objects.isNull(connectionPool))
62+
return 0;
63+
if (connectionPool.isClosed())
64+
return 0;
6165
return connectionPool.getCount(false);
6266
}
6367

6468
public int getIdleConnectionsCount() {
69+
if (Objects.isNull(connectionPool))
70+
return initialPoolSize;
71+
if (connectionPool.isClosed())
72+
return 0;
6573
return connectionPool.getCount(true);
6674
}
6775

6876
public int getTotalConnectionsCount() {
77+
if (Objects.isNull(connectionPool))
78+
return initialPoolSize;
79+
if (connectionPool.isClosed())
80+
return 0;
6981
return connectionPool.getTotalCount();
7082
}
7183

@@ -95,7 +107,6 @@ protected class SimpleDBConnectionPoolImpl {
95107
if (!poolEntry.connect(hostName, port, userId, password, initialScript, enableHighAvailability, highAvailabilitySites, reconnect, loadBalance)) {
96108
log.error(String.format("Connection %s connect failure.", poolEntry.connectionName));
97109
}
98-
;
99110
poolEntryArrayList.add(poolEntry);
100111
}
101112
poolEntries = new CopyOnWriteArrayList<>(poolEntryArrayList);

0 commit comments

Comments
 (0)