Fix a bug in SslHandler where a ClassCastException is raised when non-ByteBuf message is passed
- Fixes #1828
This commit is contained in:
parent
6ddfab3c9c
commit
02a79c51e5
@ -437,6 +437,12 @@ public class SslHandler extends ByteToMessageDecoder {
|
||||
out = ctx.alloc().buffer(maxPacketBufferSize);
|
||||
}
|
||||
|
||||
if (!(pending.msg() instanceof ByteBuf)) {
|
||||
ctx.write(pending.msg(), (ChannelPromise) pending.recycleAndGet());
|
||||
pendingUnencryptedWrites.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
ByteBuf buf = (ByteBuf) pending.msg();
|
||||
SSLEngineResult result = wrap(engine, buf, out);
|
||||
|
||||
|
@ -52,4 +52,22 @@ public class SslHandlerTest {
|
||||
assertThat(e.getCause(), is(instanceOf(SSLProtocolException.class)));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonByteBufPassthrough() throws Exception {
|
||||
SSLEngine engine = SSLContext.getDefault().createSSLEngine();
|
||||
engine.setUseClientMode(false);
|
||||
|
||||
EmbeddedChannel ch = new EmbeddedChannel(new SslHandler(engine));
|
||||
|
||||
Object msg1 = new Object();
|
||||
ch.writeOutbound(msg1);
|
||||
assertThat(ch.readOutbound(), is(sameInstance(msg1)));
|
||||
|
||||
Object msg2 = new Object();
|
||||
ch.writeInbound(msg2);
|
||||
assertThat(ch.readInbound(), is(sameInstance(msg2)));
|
||||
|
||||
ch.finish();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user