@@ -98,7 +98,8 @@ protected class SimpleDBConnectionPoolImpl {
98
98
for (int i = 0 ; i < initialPoolSize ; i ++) {
99
99
PoolEntry poolEntry = new PoolEntry (useSSL , compress , usePython , String .format ("DolphinDBConnection_%d" , i + 1 ));
100
100
if (poolEntry .connect (hostName , port , userId , password , initialScript , enableHighAvailability , highAvailabilitySites , reconnect , loadBalance )) {
101
- poolEntry .isFirstLogin .set (false );
101
+ poolEntry .isFirstConnect = false ;
102
+ poolEntry .isFirstLogin = false ;
102
103
}else {
103
104
log .error (String .format ("Connection %s connect failure." , poolEntry .connectionName ));
104
105
}
@@ -160,8 +161,8 @@ boolean isClosed() {
160
161
161
162
class PoolEntry extends DBConnection {
162
163
AtomicBoolean inUse = new AtomicBoolean (false );
163
- AtomicBoolean isFirstConnect = new AtomicBoolean ( true ) ;
164
- AtomicBoolean isFirstLogin = new AtomicBoolean ( true ) ;
164
+ volatile boolean isFirstConnect = true ;
165
+ volatile boolean isFirstLogin = true ;
165
166
String connectionName ;
166
167
167
168
PoolEntry (boolean useSSL , boolean compress , boolean usePython , String connectionName ) {
@@ -184,15 +185,15 @@ public void setLoadBalance(boolean loadBalance) {
184
185
185
186
@ Override
186
187
public boolean connect (String hostName , int port , String userId , String password , String initialScript , boolean enableHighAvailability , String [] highAvailabilitySites , boolean reconnect , boolean enableLoadBalance ) throws IOException {
187
- if (isFirstConnect . compareAndSet ( true , false ) )
188
+ if (isFirstConnect )
188
189
return super .connect (hostName , port , userId , password , initialScript , enableHighAvailability , highAvailabilitySites , reconnect , enableLoadBalance );
189
190
else
190
191
throw new RuntimeException ("The connection in connection pool can only connect by pool." );
191
192
}
192
193
193
194
@ Override
194
195
public void login (String userId , String password , boolean enableEncryption ) throws IOException {
195
- if (isFirstLogin . get () )
196
+ if (isFirstLogin )
196
197
super .login (userId , password , enableEncryption );
197
198
else
198
199
throw new RuntimeException ("The connection in connection pool can only login by pool." );
0 commit comments