@@ -98,7 +98,8 @@ protected class SimpleDBConnectionPoolImpl {
9898 for (int i = 0 ; i < initialPoolSize ; i ++) {
9999 PoolEntry poolEntry = new PoolEntry (useSSL , compress , usePython , String .format ("DolphinDBConnection_%d" , i + 1 ));
100100 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 ;
102103 }else {
103104 log .error (String .format ("Connection %s connect failure." , poolEntry .connectionName ));
104105 }
@@ -160,8 +161,8 @@ boolean isClosed() {
160161
161162 class PoolEntry extends DBConnection {
162163 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 ;
165166 String connectionName ;
166167
167168 PoolEntry (boolean useSSL , boolean compress , boolean usePython , String connectionName ) {
@@ -184,15 +185,15 @@ public void setLoadBalance(boolean loadBalance) {
184185
185186 @ Override
186187 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 )
188189 return super .connect (hostName , port , userId , password , initialScript , enableHighAvailability , highAvailabilitySites , reconnect , enableLoadBalance );
189190 else
190191 throw new RuntimeException ("The connection in connection pool can only connect by pool." );
191192 }
192193
193194 @ Override
194195 public void login (String userId , String password , boolean enableEncryption ) throws IOException {
195- if (isFirstLogin . get () )
196+ if (isFirstLogin )
196197 super .login (userId , password , enableEncryption );
197198 else
198199 throw new RuntimeException ("The connection in connection pool can only login by pool." );
0 commit comments