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

Include more details in the UnsupportedMessageTypeException when thrown #296

Merged
merged 1 commit into from
Mar 27, 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
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected void channelInputClosed(ChannelHandlerContext ctx) throws Exception {
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
if (!(msg instanceof HttpObject)) {
throw new UnsupportedMessageTypeException();
throw new UnsupportedMessageTypeException(msg, HttpObject.class);
}
// 100-continue is typically a FullHttpResponse, but the decoded
// Http3HeadersFrame should not handles as a end of stream.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.netty.channel.socket.DuplexChannel;
import io.netty.channel.socket.nio.NioDatagramChannel;
import io.netty.handler.codec.EncoderException;
import io.netty.handler.codec.UnsupportedMessageTypeException;
import io.netty.handler.codec.http.DefaultFullHttpRequest;
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import io.netty.handler.codec.http.DefaultHttpContent;
Expand Down Expand Up @@ -85,6 +86,7 @@
import static org.hamcrest.Matchers.not;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

Expand Down Expand Up @@ -1069,4 +1071,13 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
group.shutdownGracefully();
}
}

@Test
public void testUnsupportedIncludeSomeDetails() {
EmbeddedQuicStreamChannel ch = new EmbeddedQuicStreamChannel(new Http3FrameToHttpObjectCodec(false));
UnsupportedMessageTypeException ex = assertThrows(
UnsupportedMessageTypeException.class, () -> ch.writeOutbound("unsupported"));
assertNotNull(ex.getMessage());
assertFalse(ch.finish());
}
}
Loading