netty: fix server keepalive not initialized bug

fixes #2982
This commit is contained in:
ZHANG Dapeng 2017-05-12 09:05:21 -07:00 committed by GitHub
parent 870dd50eb2
commit 28ad3ba335
2 changed files with 2 additions and 12 deletions

View File

@ -334,6 +334,7 @@ class NettyServerHandler extends AbstractNettyHandler {
if (keepAliveTimeInNanos != SERVER_KEEPALIVE_TIME_NANOS_DISABLED) {
keepAliveManager = new KeepAliveManager(new KeepAlivePinger(ctx), ctx.executor(),
keepAliveTimeInNanos, keepAliveTimeoutInNanos, true /* keepAliveDuringTransportIdle */);
keepAliveManager.onTransportStarted();
}
super.handlerAdded(ctx);
}
@ -441,9 +442,6 @@ class NettyServerHandler extends AbstractNettyHandler {
@Override
public void handleProtocolNegotiationCompleted(Attributes attrs) {
attributes = transportListener.transportReady(attrs);
if (keepAliveManager != null) {
keepAliveManager.onTransportStarted();
}
}
@VisibleForTesting
@ -706,7 +704,7 @@ class NettyServerHandler extends AbstractNettyHandler {
logger.log(Level.FINE, String.format("Window: %d",
decoder().flowController().initialWindowSize(connection().connectionStream())));
}
} else {
} else if (!KEEPALIVE_PING_BUF.equals(data)) {
logger.warning("Received unexpected ping ack. No ping outstanding");
}
}

View File

@ -398,14 +398,6 @@ public class NettyServerHandlerTest extends NettyHandlerTestBase<NettyServerHand
stream = streamCaptor.getValue();
}
@Test
public void keepAliveManagerStarted() throws Exception {
manualSetUp();
verify(spyKeepAliveManager).onTransportStarted();
verify(spyKeepAliveManager, never()).onDataReceived();
verify(spyKeepAliveManager, never()).onTransportTermination();
}
@Test
public void keepAliveManagerOnDataReceived_headersRead() throws Exception {
manualSetUp();