Correctly let Http2UnkownFrame extend HttpStreamFrame and so be usable with Http2MultiplexCodec. (#7976)
Motivation: This is a followup for #7860. In the fix for #7860 we only partly fixed the problem as Http2UnknownFrame did not correctly extend HttpStreamFrame and so only worked when using the Http2FrameCodec. We need to have it extend HttpStreamFrame as otherwise Http2MultiplexCodec will reject to handle it correctly. Modifications: - Let Http2UnknownFrame extend HttpStreamFrame - Add unit tests for writing and reading Http2UnkownFrame instances when the Http2MultiplexCodec is used. Result: Fixes https://github.com/netty/netty/issues/7969.
This commit is contained in:
parent
7f59896fba
commit
f904c63a53
@ -20,13 +20,12 @@ import io.netty.buffer.ByteBufHolder;
|
||||
import io.netty.util.internal.UnstableApi;
|
||||
|
||||
@UnstableApi
|
||||
public interface Http2UnknownFrame extends Http2Frame, ByteBufHolder {
|
||||
public interface Http2UnknownFrame extends Http2StreamFrame, ByteBufHolder {
|
||||
|
||||
@Override
|
||||
Http2FrameStream stream();
|
||||
|
||||
/**
|
||||
* Set the {@link Http2FrameStream} object for this frame.
|
||||
*/
|
||||
@Override
|
||||
Http2UnknownFrame stream(Http2FrameStream stream);
|
||||
|
||||
byte frameType();
|
||||
|
@ -104,6 +104,43 @@ public class Http2MultiplexCodecTest {
|
||||
// TODO(buchgr): GOAWAY Logic
|
||||
// TODO(buchgr): Test ChannelConfig.setMaxMessagesPerRead
|
||||
|
||||
@Test
|
||||
public void writeUnknownFrame() {
|
||||
childChannelInitializer.handler = new ChannelInboundHandlerAdapter() {
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) {
|
||||
ctx.writeAndFlush(new DefaultHttp2HeadersFrame(new DefaultHttp2Headers()));
|
||||
ctx.writeAndFlush(new DefaultHttp2UnknownFrame((byte) 99, new Http2Flags()));
|
||||
ctx.fireChannelActive();
|
||||
}
|
||||
};
|
||||
|
||||
Channel childChannel = newOutboundStream();
|
||||
assertTrue(childChannel.isActive());
|
||||
|
||||
Http2FrameStream stream = readOutboundHeadersAndAssignId();
|
||||
parentChannel.runPendingTasks();
|
||||
|
||||
Http2UnknownFrame frame = parentChannel.readOutbound();
|
||||
assertEquals(stream, frame.stream());
|
||||
assertEquals(99, frame.frameType());
|
||||
assertEquals(new Http2Flags(), frame.flags());
|
||||
frame.release();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readUnkownFrame() {
|
||||
LastInboundHandler inboundHandler = streamActiveAndWriteHeaders(inboundStream);
|
||||
codec.onHttp2Frame(new DefaultHttp2UnknownFrame((byte) 99, new Http2Flags()).stream(inboundStream));
|
||||
codec.onChannelReadComplete();
|
||||
|
||||
// headers and unknown frame
|
||||
verifyFramesMultiplexedToCorrectChannel(inboundStream, inboundHandler, 2);
|
||||
|
||||
Channel childChannel = newOutboundStream();
|
||||
assertTrue(childChannel.isActive());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headerAndDataFramesShouldBeDelivered() {
|
||||
LastInboundHandler inboundHandler = new LastInboundHandler();
|
||||
|
Loading…
Reference in New Issue
Block a user