Skip to content

Commit

Permalink
make Connection.isFine check Connection's closed state (#340)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrezzerO authored Feb 21, 2024
1 parent 6b127c1 commit efeb15a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/com/alipay/remoting/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private void init() {
* @return true if connection is fine
*/
public boolean isFine() {
return this.channel != null && this.channel.isActive();
return this.channel != null && this.channel.isActive() && !closed.get();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package com.alipay.remoting.inner.connection;

import com.alipay.remoting.exception.RemotingException;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
Expand Down Expand Up @@ -123,4 +124,11 @@ public void connectionTest() throws Exception {
Thread.sleep(100);
Assert.assertEquals(3, serverConnectProcessor.getConnectTimes());
}

@Test
public void testIsFine() throws RemotingException {
Connection conn = client.createStandaloneConnection(ip, port, 1000);
conn.close();
Assert.assertFalse(conn.isFine());
}
}

0 comments on commit efeb15a

Please sign in to comment.