Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add closed check in Connection's isFine #340

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}
Loading