Skip to content

Commit 137b2dc

Browse files
committed
DUBBO-424 Heartbeat response不应该在业务线程处理
1 parent 20c1f7f commit 137b2dc

File tree

1 file changed

+18
-0
lines changed
  • dubbo-remoting/dubbo-remoting-netty/src/test/java/com/alibaba/dubbo/remoting/exchange/support/header

1 file changed

+18
-0
lines changed

dubbo-remoting/dubbo-remoting-netty/src/test/java/com/alibaba/dubbo/remoting/exchange/support/header/HeartbeatHandlerTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ public class HeartbeatHandlerTest {
4444
public void after() throws Exception {
4545
if (client != null) {
4646
client.close();
47+
client = null;
4748
}
4849

4950
if (server != null) {
5051
server.close();
52+
server = null;
5153
}
5254
}
5355

@@ -67,6 +69,22 @@ public void testServerHeartbeat() throws Exception {
6769
System.out.println("disconnect count " + handler.disconnectCount);
6870
}
6971

72+
@Test
73+
public void testHeartbeat() throws Exception {
74+
URL serverURL = URL.valueOf("header://localhost:55555");
75+
serverURL = serverURL.addParameter(Constants.HEARTBEAT_KEY, 1000);
76+
TestHeartbeatHandler handler = new TestHeartbeatHandler();
77+
server = Exchangers.bind(serverURL, handler);
78+
System.out.println("Server bind successfully");
79+
80+
client = Exchangers.connect(serverURL);
81+
Thread.sleep(10000);
82+
System.err.println("++++++++++++++ disconnect count " + handler.disconnectCount);
83+
System.err.println("++++++++++++++ connect count " + handler.connectCount);
84+
Assert.assertTrue(handler.disconnectCount == 0);
85+
Assert.assertTrue(handler.connectCount == 1);
86+
}
87+
7088
@Test
7189
public void testClientHeartbeat() throws Exception {
7290
FakeChannelHandlers.setTestingChannelHandlers();

0 commit comments

Comments
 (0)