NettyServerHandler extends AbstractNettyHandler { @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { try { final Status status = Status.UNAVAILABLE.withDescription("connection terminated for unknown reason"); connection().forEachActiveStream(new Http2StreamVisitor() { @Override public boolean visit(Http2Stream stream) throws Http2Exception { NettyServerStream serverStream = serverStream(stream); if (serverStream != null) { serverStream.abortStream(status, false); } return true; } }); } finally { super.channelInactive(ctx); } } private  NettyServerHandler(ServerTransportListener transportListener,
                             Http2ConnectionDecoder decoder,
                             Http2ConnectionEncoder encoder, Http2Settings settings,
                             int maxMessageSize); @Override void handlerAdded(ChannelHandlerContext ctx); @Override void channelInactive(ChannelHandlerContext ctx); @Override void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise);  }
@Test public void channelInactiveShouldCloseStreams() throws Exception { createStream(); handler().channelInactive(ctx()); ArgumentCaptor<Status> captor = ArgumentCaptor.forClass(Status.class); verify(streamListener).closed(captor.capture()); assertFalse(captor.getValue().isOk()); }