Repository: netty/netty (Java)

Issue:
Blocking call found with Spring Webflux and r2dbc-mysql driver.
### Overview
Hi, 
So I am using Spring Webflux 5.3.1(which internally uses Netty) and I am integrating it with a MySql R2DBC driver(r2dbc-mysql) to make a reactive application. 
It works fine and everything looks good.
But when I tried to use BlockHound(a tool created by the Spring team to detect blocking calls), to make sure that my API is non-blocking end-to-end but it shows that there is a blocking call when I installed BlockHound.

### Expected behavior
It should have run smoothly with/without BlockHound.

### Actual behavior
BlockHound says that there is a blocking call. PFB the full stack trace and below it the part of stack trace where block hound tells the blocking call is.
```
2020-12-03 15:24:23,442 INFO  [main] o.s.b.w.e.n.NettyWebServer:109:[, ] - Netty started on port(s): 8080
2020-12-03 15:24:23,461 INFO  [main] c.m.d.DdReactiveApplication:61:[, ] - Started DdReactiveApplication in 3.946 seconds (JVM running for 4.569)
2020-12-03 15:24:35,151 ERROR [reactor-tcp-epoll-2] o.s.b.a.w.r.e.AbstractErrorWebExceptionHandler:122:[, ] - [f05df953-2]  500 Server Error for HTTP GET "/getAllExpFromDB"
org.springframework.dao.DataAccessResourceFailureException: executeMany; SQL [SELECT dd_reactive.* FROM dd_reactive]; null; nested exception is dev.miku.r2dbc.mysql.client.MySqlConnectionException
	at org.springframework.r2dbc.connection.ConnectionFactoryUtils.convertR2dbcException(ConnectionFactoryUtils.java:226)
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
	|_ checkpoint ⇢ Handler com.mmt.ddreactive.controller.DDController#getAllExperimentsFromDB(String) [DispatcherHandler]
	|_ checkpoint ⇢ HTTP GET "/getAllExpFromDB" [ExceptionHandlingWebHandler]
Stack trace:
		at org.springframework.r2dbc.connection.ConnectionFactoryUtils.convertR2dbcException(ConnectionFactoryUtils.java:226)
		at org.springframework.r2dbc.core.DefaultDatabaseClient.lambda$inConnectionMany$8(DefaultDatabaseClient.java:147)
		at reactor.core.publisher.Flux.lambda$onErrorMap$28(Flux.java:6579)
		at reactor.core.publisher.Flux.lambda$onErrorResume$29(Flux.java:6632)
		at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:94)
		at reactor.core.publisher.FluxUsingWhen$UsingWhenSubscriber.deferredError(FluxUsingWhen.java:411)
		at reactor.core.publisher.FluxUsingWhen$RollbackInner.onComplete(FluxUsingWhen.java:488)
		at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onComplete(Operators.java:2018)
		at reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:259)
		at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onComplete(Operators.java:2018)
		at reactor.core.publisher.Operators$MonoSubscriber.onComplete(Operators.java:1826)
		at reactor.core.publisher.MonoIgnoreThen$ThenAcceptInner.onComplete(MonoIgnoreThen.java:323)
		at reactor.core.publisher.Operators$MonoSubscriber.onComplete(Operators.java:1826)
		at reactor.core.publisher.MonoIgnoreThen$ThenAcceptInner.onComplete(MonoIgnoreThen.java:323)
		at reactor.pool.SimpleDequePool$QueuePoolRecyclerInner.onComplete(SimpleDequePool.java:624)
		at reactor.core.publisher.Operators.complete(Operators.java:135)
		at reactor.core.publisher.MonoEmpty.subscribe(MonoEmpty.java:45)
		at reactor.core.publisher.Mono.subscribe(Mono.java:3987)
		at reactor.pool.SimpleDequePool$QueuePoolRecyclerMono.subscribe(SimpleDequePool.java:736)
		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
		at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:154)
		at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56)
		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
		at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:154)
		at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56)
		at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
		at reactor.core.publisher.Mono.subscribe(Mono.java:3987)
		at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:103)
		at reactor.core.publisher.MonoIgnoreElements$IgnoreElementsSubscriber.onError(MonoIgnoreElements.java:83)
		at reactor.core.publisher.FluxMap$MapSubscriber.onError(FluxMap.java:132)
		at reactor.core.publisher.FluxFilter$FilterSubscriber.onError(FluxFilter.java:157)
		at reactor.core.publisher.FluxFilter$FilterConditionalSubscriber.onError(FluxFilter.java:291)
		at reactor.core.publisher.FluxMap$MapConditionalSubscriber.onError(FluxMap.java:259)
		at reactor.core.publisher.Operators.error(Operators.java:196)
		at reactor.core.publisher.MonoError.subscribe(MonoError.java:52)
		at reactor.core.publisher.MonoDeferContextual.subscribe(MonoDeferContextual.java:55)
		at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
		at reactor.core.publisher.Mono.subscribe(Mono.java:3987)
		at reactor.core.publisher.FluxUsingWhen$UsingWhenSubscriber.onError(FluxUsingWhen.java:377)
		at reactor.core.publisher.FluxFlatMap$FlatMapMain.checkTerminated(FluxFlatMap.java:841)
		at reactor.core.publisher.FluxFlatMap$FlatMapMain.drainLoop(FluxFlatMap.java:607)
		at reactor.core.publisher.FluxFlatMap$FlatMapMain.drain(FluxFlatMap.java:587)
		at reactor.core.publisher.FluxFlatMap$FlatMapMain.onError(FluxFlatMap.java:450)
		at reactor.core.publisher.FluxMap$MapSubscriber.onError(FluxMap.java:132)
		at reactor.core.publisher.FluxMap$MapSubscriber.onError(FluxMap.java:132)
		at reactor.core.publisher.FluxWindowPredicate$WindowPredicateMain.signalAsyncError(FluxWindowPredicate.java:341)
		at reactor.core.publisher.FluxWindowPredicate$WindowPredicateMain.checkTerminated(FluxWindowPredicate.java:523)
		at reactor.core.publisher.FluxWindowPredicate$WindowPredicateMain.drainLoop(FluxWindowPredicate.java:475)
		at reactor.core.publisher.FluxWindowPredicate$WindowPredicateMain.drain(FluxWindowPredicate.java:419)
		at reactor.core.publisher.FluxWindowPredicate$WindowPredicateMain.onError(FluxWindowPredicate.java:278)
		at reactor.core.publisher.FluxHandleFuseable$HandleFuseableSubscriber.onError(FluxHandleFuseable.java:219)
		at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onError(FluxContextWrite.java:121)
		at dev.miku.r2dbc.mysql.util.DiscardOnCancelSubscriber.onError(DiscardOnCancelSubscriber.java:87)
		at reactor.core.publisher.FluxPeekFuseable$PeekConditionalSubscriber.onError(FluxPeekFuseable.java:903)
		at reactor.core.publisher.MonoFlatMapMany$FlatMapManyInner.onError(MonoFlatMapMany.java:255)
		at reactor.core.publisher.FluxPeek$PeekSubscriber.onError(FluxPeek.java:221)
		at reactor.core.publisher.FluxHandle$HandleSubscriber.onError(FluxHandle.java:202)
		at reactor.core.publisher.FluxPeekFuseable$PeekConditionalSubscriber.onError(FluxPeekFuseable.java:903)
		at reactor.core.publisher.EmitterProcessor.checkTerminated(EmitterProcessor.java:535)
		at reactor.core.publisher.EmitterProcessor.drain(EmitterProcessor.java:402)
		at reactor.core.publisher.EmitterProcessor.tryEmitError(EmitterProcessor.java:238)
		at reactor.core.publisher.InternalManySink.emitError(InternalManySink.java:98)
		at reactor.core.publisher.EmitterProcessor.onError(EmitterProcessor.java:227)
		at dev.miku.r2dbc.mysql.client.ReactorNettyClient.drainError(ReactorNettyClient.java:254)
		at dev.miku.r2dbc.mysql.client.ReactorNettyClient.resumeError(ReactorNettyClient.java:214)
		at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:94)
		at reactor.core.publisher.FluxPeek$PeekSubscriber.onError(FluxPeek.java:221)
		at reactor.netty.channel.FluxReceive.terminateReceiver(FluxReceive.java:447)
		at reactor.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:256)
		at reactor.netty.channel.FluxReceive.onInboundError(FluxReceive.java:435)
		at reactor.netty.channel.ChannelOperations.onInboundError(ChannelOperations.java:467)
		at reactor.netty.channel.ChannelOperationsHandler.exceptionCaught(ChannelOperationsHandler.java:127)
		at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:302)
		at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:281)
		at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:273)
		at io.netty.handler.ssl.SslHandler.exceptionCaught(SslHandler.java:1151)
		at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:302)
		at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:752)
		at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:742)
		at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:728)
		at dev.miku.r2dbc.mysql.client.WriteSubscriber.onComplete(WriteSubscriber.java:72)
		at reactor.core.publisher.FluxCreate$BaseSink.complete(FluxCreate.java:439)
		at reactor.core.publisher.FluxCreate$BufferAsyncSink.drain(FluxCreate.java:784)
		at reactor.core.publisher.FluxCreate$BufferAsyncSink.complete(FluxCreate.java:732)
		at reactor.core.publisher.FluxCreate$SerializedFluxSink.drainLoop(FluxCreate.java:240)
		at reactor.core.publisher.FluxCreate$SerializedFluxSink.drain(FluxCreate.java:206)
		at reactor.core.publisher.FluxCreate$SerializedFluxSink.complete(FluxCreate.java:197)
		at dev.miku.r2dbc.mysql.message.client.LargeMessageSlicer.onComplete(LargeMessageSlicer.java:99)
		at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2348)
		at dev.miku.r2dbc.mysql.message.client.LargeMessageSlicer.onSubscribe(LargeMessageSlicer.java:48)
		at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54)
		at reactor.core.publisher.Mono.subscribe(Mono.java:3987)
		at dev.miku.r2dbc.mysql.message.client.LargeClientMessage.lambda$encode$0(LargeClientMessage.java:52)
		at reactor.core.publisher.FluxCreate.subscribe(FluxCreate.java:94)
		at reactor.core.publisher.Flux.subscribe(Flux.java:8095)
		at dev.miku.r2dbc.mysql.client.MessageDuplexCodec.write(MessageDuplexCodec.java:111)
		at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717)
		at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:764)
		at io.netty.channel.AbstractChannelHandlerContext$WriteTask.run(AbstractChannelHandlerContext.java:1071)
		at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
		at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
		at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:384)
		at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
		at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
		at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
		at java.lang.Thread.run(Thread.java:748)
Caused by: dev.miku.r2dbc.mysql.client.MySqlConnectionException: null
	at dev.miku.r2dbc.mysql.client.ClientExceptions.wrap(ClientExceptions.java:47)
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
	|_ checkpoint ⇢ SQL "SELECT dd_reactive.* FROM dd_reactive" [DatabaseClient]
Stack trace:
		at dev.miku.r2dbc.mysql.client.ClientExceptions.wrap(ClientExceptions.java:47)
		at dev.miku.r2dbc.mysql.client.ReactorNettyClient.resumeError(ReactorNettyClient.java:214)
		at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:94)
		at reactor.core.publisher.FluxPeek$PeekSubscriber.onError(FluxPeek.java:221)
		at reactor.netty.channel.FluxReceive.terminateReceiver(FluxReceive.java:447)
		at reactor.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:256)
		at reactor.netty.channel.FluxReceive.onInboundError(FluxReceive.java:435)
		at reactor.netty.channel.ChannelOperations.onInboundError(ChannelOperations.java:467)
		at reactor.netty.channel.ChannelOperationsHandler.exceptionCaught(ChannelOperationsHandler.java:127)
		at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:302)
		at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:281)
		at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:273)
		at io.netty.handler.ssl.SslHandler.exceptionCaught(SslHandler.java:1151)
		at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:302)
		at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:752)
		at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:742)
		at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:728)
		at dev.miku.r2dbc.mysql.client.WriteSubscriber.onComplete(WriteSubscriber.java:72)
		at reactor.core.publisher.FluxCreate$BaseSink.complete(FluxCreate.java:439)
		at reactor.core.publisher.FluxCreate$BufferAsyncSink.drain(FluxCreate.java:784)
		at reactor.core.publisher.FluxCreate$BufferAsyncSink.complete(FluxCreate.java:732)
		at reactor.core.publisher.FluxCreate$SerializedFluxSink.drainLoop(FluxCreate.java:240)
		at reactor.core.publisher.FluxCreate$SerializedFluxSink.drain(FluxCreate.java:206)
		at reactor.core.publisher.FluxCreate$SerializedFluxSink.complete(FluxCreate.java:197)
		at dev.miku.r2dbc.mysql.message.client.LargeMessageSlicer.onComplete(LargeMessageSlicer.java:99)
		at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2348)
		at dev.miku.r2dbc.mysql.message.client.LargeMessageSlicer.onSubscribe(LargeMessageSlicer.java:48)
		at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54)
		at reactor.core.publisher.Mono.subscribe(Mono.java:3987)
		at dev.miku.r2dbc.mysql.message.client.LargeClientMessage.lambda$encode$0(LargeClientMessage.java:52)
		at reactor.core.publisher.FluxCreate.subscribe(FluxCreate.java:94)
		at reactor.core.publisher.Flux.subscribe(Flux.java:8095)
		at dev.miku.r2dbc.mysql.client.MessageDuplexCodec.write(MessageDuplexCodec.java:111)
		at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717)
		at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:764)
		at io.netty.channel.AbstractChannelHandlerContext$WriteTask.run(AbstractChannelHandlerContext.java:1071)
		at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
		at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
		at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:384)
		at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
		at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
		at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
		at java.lang.Thread.run(Thread.java:748)
Caused by: reactor.blockhound.BlockingOperationError: Blocking call! java.io.FileInputStream#readBytes
	at java.io.FileInputStream.readBytes(FileInputStream.java)
	at java.io.FileInputStream.read(FileInputStream.java:255)
	at sun.security.provider.NativePRNG$RandomIO.readFully(NativePRNG.java:424)
	at sun.security.provider.NativePRNG$RandomIO.ensureBufferValid(NativePRNG.java:526)
	at sun.security.provider.NativePRNG$RandomIO.implNextBytes(NativePRNG.java:545)
	at sun.security.provider.NativePRNG$RandomIO.access$400(NativePRNG.java:331)
	at sun.security.provider.NativePRNG.engineNextBytes(NativePRNG.java:220)
	at java.security.SecureRandom.nextBytes(SecureRandom.java:468)
	at sun.security.ssl.CipherBox.createExplicitNonce(CipherBox.java:1025)
	at sun.security.ssl.EngineOutputRecord.write(EngineOutputRecord.java:287)
	at sun.security.ssl.EngineOutputRecord.write(EngineOutputRecord.java:225)
	at sun.security.ssl.EngineWriter.writeRecord(EngineWriter.java:186)
	at sun.security.ssl.SSLEngineImpl.writeRecord(SSLEngineImpl.java:1281)
	at sun.security.ssl.SSLEngineImpl.writeAppRecord(SSLEngineImpl.java:1252)
	at sun.security.ssl.SSLEngineImpl.wrap(SSLEngineImpl.java:1165)
	at javax.net.ssl.SSLEngine.wrap(SSLEngine.java:509)
	at io.netty.handler.ssl.SslHandler.wrap(SslHandler.java:1086)
	at io.netty.handler.ssl.SslHandler.wrap(SslHandler.java:843)
	at io.netty.handler.ssl.SslHandler.wrapAndFlush(SslHandler.java:811)
	at io.netty.handler.ssl.SslHandler.flush(SslHandler.java:792)
	at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:750)
	at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:742)
	at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:728)
	at dev.miku.r2dbc.mysql.client.WriteSubscriber.onComplete(WriteSubscriber.java:72)
	at reactor.core.publisher.FluxCreate$BaseSink.complete(FluxCreate.java:439)
	at reactor.core.publisher.FluxCreate$BufferAsyncSink.drain(FluxCreate.java:784)
	at reactor.core.publisher.FluxCreate$BufferAsyncSink.complete(FluxCreate.java:732)
	at reactor.core.publisher.FluxCreate$SerializedFluxSink.drainLoop(FluxCreate.java:240)
	at reactor.core.publisher.FluxCreate$SerializedFluxSink.drain(FluxCreate.java:206)
	at reactor.core.publisher.FluxCreate$SerializedFluxSink.complete(FluxCreate.java:197)
	at dev.miku.r2dbc.mysql.message.client.LargeMessageSlicer.onComplete(LargeMessageSlicer.java:99)
	at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2348)
	at dev.miku.r2dbc.mysql.message.client.LargeMessageSlicer.onSubscribe(LargeMessageSlicer.java:48)
	at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3987)
	at dev.miku.r2dbc.mysql.message.client.LargeClientMessage.lambda$encode$0(LargeClientMessage.java:52)
	at reactor.core.publisher.FluxCreate.subscribe(FluxCreate.java:94)
	at reactor.core.publisher.Flux.subscribe(Flux.java:8095)
	at dev.miku.r2dbc.mysql.client.MessageDuplexCodec.write(MessageDuplexCodec.java:111)
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717)
	at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:764)
	at io.netty.channel.AbstractChannelHandlerContext$WriteTask.run(AbstractChannelHandlerContext.java:1071)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:384)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)
2020-12-03 15:24:35,195 WARN  [reactor-tcp-epoll-2] d.m.r.m.c.ReactorNettyClient:259:[, ] - Connection has been closed by peer
2020-12-03 15:24:35,196 ERROR [reactor-tcp-epoll-2] r.c.p.Operators:319:[, ] - Operator called default onErrorDropped
dev.miku.r2dbc.mysql.client.MySqlConnectionClosedException: Connection unexpectedly closed
	at dev.miku.r2dbc.mysql.client.ClientExceptions.unexpectedClosed(ClientExceptions.java:32)
	at dev.miku.r2dbc.mysql.client.ReactorNettyClient.handleClose(ReactorNettyClient.java:260)
	at reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:264)
	at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onComplete(Operators.java:2018)
	at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:366)
	at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onComplete(FluxConcatMap.java:275)
	at reactor.core.publisher.EmitterProcessor.checkTerminated(EmitterProcessor.java:541)
	at reactor.core.publisher.EmitterProcessor.drain(EmitterProcessor.java:402)
	at reactor.core.publisher.EmitterProcessor.tryEmitComplete(EmitterProcessor.java:221)
	at reactor.core.publisher.EmitterProcessor.onComplete(EmitterProcessor.java:212)
	at dev.miku.r2dbc.mysql.client.ReactorNettyClient.resumeError(ReactorNettyClient.java:215)
	at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:94)
	at reactor.core.publisher.FluxPeek$PeekSubscriber.onError(FluxPeek.java:221)
	at reactor.netty.channel.FluxReceive.terminateReceiver(FluxReceive.java:447)
	at reactor.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:256)
	at reactor.netty.channel.FluxReceive.onInboundError(FluxReceive.java:435)
	at reactor.netty.channel.ChannelOperations.onInboundError(ChannelOperations.java:467)
	at reactor.netty.channel.ChannelOperationsHandler.exceptionCaught(ChannelOperationsHandler.java:127)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:302)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:281)
	at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:273)
	at io.netty.handler.ssl.SslHandler.exceptionCaught(SslHandler.java:1151)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:302)
	at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:752)
	at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:742)
	at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:728)
	at dev.miku.r2dbc.mysql.client.WriteSubscriber.onComplete(WriteSubscriber.java:72)
	at reactor.core.publisher.FluxCreate$BaseSink.complete(FluxCreate.java:439)
	at reactor.core.publisher.FluxCreate$BufferAsyncSink.drain(FluxCreate.java:784)
	at reactor.core.publisher.FluxCreate$BufferAsyncSink.complete(FluxCreate.java:732)
	at reactor.core.publisher.FluxCreate$SerializedFluxSink.drainLoop(FluxCreate.java:240)
	at reactor.core.publisher.FluxCreate$SerializedFluxSink.drain(FluxCreate.java:206)
	at reactor.core.publisher.FluxCreate$SerializedFluxSink.complete(FluxCreate.java:197)
	at dev.miku.r2dbc.mysql.message.client.LargeMessageSlicer.onComplete(LargeMessageSlicer.java:99)
	at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2348)
	at dev.miku.r2dbc.mysql.message.client.LargeMessageSlicer.onSubscribe(LargeMessageSlicer.java:48)
	at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3987)
	at dev.miku.r2dbc.mysql.message.client.LargeClientMessage.lambda$encode$0(LargeClientMessage.java:52)
	at reactor.core.publisher.FluxCreate.subscribe(FluxCreate.java:94)
	at reactor.core.publisher.Flux.subscribe(Flux.java:8095)
	at dev.miku.r2dbc.mysql.client.MessageDuplexCodec.write(MessageDuplexCodec.java:111)
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717)
	at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:764)
	at io.netty.channel.AbstractChannelHandlerContext$WriteTask.run(AbstractChannelHandlerContext.java:1071)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:384)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)
2020-12-03 15:24:35,197 ERROR [reactor-tcp-epoll-2] d.m.r.m.c.ReactorNettyClient:217:[, ] - Error: Blocking call! java.io.FileInputStream#readBytes
reactor.blockhound.BlockingOperationError: Blocking call! java.io.FileInputStream#readBytes
	at java.io.FileInputStream.readBytes(FileInputStream.java)
	at java.io.FileInputStream.read(FileInputStream.java:255)
	at sun.security.provider.NativePRNG$RandomIO.readFully(NativePRNG.java:424)
	at sun.security.provider.NativePRNG$RandomIO.ensureBufferValid(NativePRNG.java:526)
	at sun.security.provider.NativePRNG$RandomIO.implNextBytes(NativePRNG.java:545)
	at sun.security.provider.NativePRNG$RandomIO.access$400(NativePRNG.java:331)
	at sun.security.provider.NativePRNG.engineNextBytes(NativePRNG.java:220)
	at java.security.SecureRandom.nextBytes(SecureRandom.java:468)
	at sun.security.ssl.CipherBox.createExplicitNonce(CipherBox.java:1025)
	at sun.security.ssl.EngineOutputRecord.write(EngineOutputRecord.java:287)
	at sun.security.ssl.EngineOutputRecord.write(EngineOutputRecord.java:225)
	at sun.security.ssl.EngineWriter.writeRecord(EngineWriter.java:186)
	at sun.security.ssl.SSLEngineImpl.writeRecord(SSLEngineImpl.java:1281)
	at sun.security.ssl.SSLEngineImpl.writeAppRecord(SSLEngineImpl.java:1252)
	at sun.security.ssl.SSLEngineImpl.wrap(SSLEngineImpl.java:1165)
	at javax.net.ssl.SSLEngine.wrap(SSLEngine.java:509)
	at io.netty.handler.ssl.SslHandler.wrap(SslHandler.java:1086)
	at io.netty.handler.ssl.SslHandler.wrap(SslHandler.java:843)
	at io.netty.handler.ssl.SslHandler.wrapAndFlush(SslHandler.java:811)
	at io.netty.handler.ssl.SslHandler.flush(SslHandler.java:792)
	at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:750)
	at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:742)
	at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:728)
	at dev.miku.r2dbc.mysql.client.WriteSubscriber.onComplete(WriteSubscriber.java:72)
	at reactor.core.publisher.FluxCreate$BaseSink.complete(FluxCreate.java:439)
	at reactor.core.publisher.FluxCreate$BufferAsyncSink.drain(FluxCreate.java:784)
	at reactor.core.publisher.FluxCreate$BufferAsyncSink.complete(FluxCreate.java:732)
	at reactor.core.publisher.FluxCreate$SerializedFluxSink.drainLoop(FluxCreate.java:240)
	at reactor.core.publisher.FluxCreate$SerializedFluxSink.drain(FluxCreate.java:206)
	at reactor.core.publisher.FluxCreate$SerializedFluxSink.complete(FluxCreate.java:197)
	at dev.miku.r2dbc.mysql.message.client.LargeMessageSlicer.onComplete(LargeMessageSlicer.java:99)
	at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2348)
	at dev.miku.r2dbc.mysql.message.client.LargeMessageSlicer.onSubscribe(LargeMessageSlicer.java:48)
	at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3987)
	at dev.miku.r2dbc.mysql.message.client.LargeClientMessage.lambda$encode$0(LargeClientMessage.java:52)
	at reactor.core.publisher.FluxCreate.subscribe(FluxCreate.java:94)
	at reactor.core.publisher.Flux.subscribe(Flux.java:8095)
	at dev.miku.r2dbc.mysql.client.MessageDuplexCodec.write(MessageDuplexCodec.java:111)
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717)
	at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:764)
	at io.netty.channel.AbstractChannelHandlerContext$WriteTask.run(AbstractChannelHandlerContext.java:1071)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:384)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)
2020-12-03 15:24:35,207 ERROR [reactor-tcp-epoll-2] r.c.p.Operators:319:[, ] - Operator called default onErrorDropped
dev.miku.r2dbc.mysql.client.MySqlConnectionClosedException: Connection closed
	at dev.miku.r2dbc.mysql.client.ClientExceptions.expectedClosed(ClientExceptions.java:36)
	at dev.miku.r2dbc.mysql.client.ReactorNettyClient.handleClose(ReactorNettyClient.java:262)
	at dev.miku.r2dbc.mysql.client.ReactorNettyClient.access$400(ReactorNettyClient.java:53)
	at dev.miku.r2dbc.mysql.client.ReactorNettyClient$ResponseSubscriber.onComplete(ReactorNettyClient.java:306)
	at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onComplete(Operators.java:2018)
	at reactor.core.publisher.Operators$MonoSubscriber.onComplete(Operators.java:1826)
	at reactor.core.publisher.MonoIgnoreThen$ThenAcceptInner.onComplete(MonoIgnoreThen.java:323)
	at reactor.core.publisher.Operators.complete(Operators.java:135)
	at reactor.netty.FutureMono$DeferredFutureMono.subscribe(FutureMono.java:131)
	at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:154)
	at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3987)
	at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:103)
	at reactor.core.publisher.FluxPeek$PeekSubscriber.onError(FluxPeek.java:221)
	at reactor.netty.channel.FluxReceive.terminateReceiver(FluxReceive.java:447)
	at reactor.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:256)
	at reactor.netty.channel.FluxReceive.onInboundError(FluxReceive.java:435)
	at reactor.netty.channel.ChannelOperations.onInboundError(ChannelOperations.java:467)
	at reactor.netty.channel.ChannelOperationsHandler.exceptionCaught(ChannelOperationsHandler.java:127)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:302)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:281)
	at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:273)
	at io.netty.handler.ssl.SslHandler.exceptionCaught(SslHandler.java:1151)
	at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:302)
	at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:752)
	at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:742)
	at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:728)
	at dev.miku.r2dbc.mysql.client.WriteSubscriber.onComplete(WriteSubscriber.java:72)
	at reactor.core.publisher.FluxCreate$BaseSink.complete(FluxCreate.java:439)
	at reactor.core.publisher.FluxCreate$BufferAsyncSink.drain(FluxCreate.java:784)
	at reactor.core.publisher.FluxCreate$BufferAsyncSink.complete(FluxCreate.java:732)
	at reactor.core.publisher.FluxCreate$SerializedFluxSink.drainLoop(FluxCreate.java:240)
	at reactor.core.publisher.FluxCreate$SerializedFluxSink.drain(FluxCreate.java:206)
	at reactor.core.publisher.FluxCreate$SerializedFluxSink.complete(FluxCreate.java:197)
	at dev.miku.r2dbc.mysql.message.client.LargeMessageSlicer.onComplete(LargeMessageSlicer.java:99)
	at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2348)
	at dev.miku.r2dbc.mysql.message.client.LargeMessageSlicer.onSubscribe(LargeMessageSlicer.java:48)
	at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54)
	at reactor.core.publisher.Mono.subscribe(Mono.java:3987)
	at dev.miku.r2dbc.mysql.message.client.LargeClientMessage.lambda$encode$0(LargeClientMessage.java:52)
	at reactor.core.publisher.FluxCreate.subscribe(FluxCreate.java:94)
	at reactor.core.publisher.Flux.subscribe(Flux.java:8095)
	at dev.miku.r2dbc.mysql.client.MessageDuplexCodec.write(MessageDuplexCodec.java:111)
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717)
	at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:764)
	at io.netty.channel.AbstractChannelHandlerContext$WriteTask.run(AbstractChannelHandlerContext.java:1071)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:384)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)
```

Part of stack trace where blockhound found the blocking call:

```
2020-12-03 15:24:35,197 ERROR [reactor-tcp-epoll-2] d.m.r.m.c.ReactorNettyClient:217:[, ] - Error: Blocking call! java.io.FileInputStream#readBytes
reactor.blockhound.BlockingOperationError: Blocking call! java.io.FileInputStream#readBytes
	at java.io.FileInputStream.readBytes(FileInputStream.java)
	at java.io.FileInputStream.read(FileInputStream.java:255)
	at sun.security.provider.NativePRNG$RandomIO.readFully(NativePRNG.java:424)
	at sun.security.provider.NativePRNG$RandomIO.ensureBufferValid(NativePRNG.java:526)
	at sun.security.provider.NativePRNG$RandomIO.implNextBytes(NativePRNG.java:545)
	at sun.security.provider.NativePRNG$RandomIO.access$400(NativePRNG.java:331)
	at sun.security.provider.NativePRNG.engineNextBytes(NativePRNG.java:220)
	at java.security.SecureRandom.nextBytes(SecureRandom.java:468)
	at sun.security.ssl.CipherBox.createExplicitNonce(CipherBox.java:1025)
	at sun.security.ssl.EngineOutputRecord.write(EngineOutputRecord.java:287)
	at sun.security.ssl.EngineOutputRecord.write(EngineOutputRecord.java:225)
	at sun.security.ssl.EngineWriter.writeRecord(EngineWriter.java:186)
	at sun.security.ssl.SSLEngineImpl.writeRecord(SSLEngineImpl.java:1281)
	at sun.security.ssl.SSLEngineImpl.writeAppRecord(SSLEngineImpl.java:1252)
	at sun.security.ssl.SSLEngineImpl.wrap(SSLEngineImpl.java:1165)
	at javax.net.ssl.SSLEngine.wrap(SSLEngine.java:509)
	at io.netty.handler.ssl.SslHandler.wrap(SslHandler.java:1086)
	at io.netty.handler.ssl.SslHandler.wrap(SslHandler.java:843)
	at io.netty.handler.ssl.SslHandler.wrapAndFlush(SslHandler.java:811)
	at io.netty.handler.ssl.SslHandler.flush(SslHandler.java:792)
	at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:750)
	at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:742)
	at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:728)
	at dev.miku.r2dbc.mysql.client.WriteSubscriber.onComplete(WriteSubscriber.java:72)
```



### Steps to reproduce
I made a few DB calls here and there and was able to produce the blockhound exception, an overview of what I did was, first I hit an API which fetched few rows from a table from DB using the @Query("select * from dd_reactive where id in (:listOfIds)") (without blockhound) this works fine, then I hit another API which made another call to DB to fetch all the rows of the table (with blockhound), it breaks here with the stack trace pasted above.

### Minimal yet complete reproducer code (or URL to code)
If needed I can provide the code later on.

### Netty version
4.1.54.Final
### JVM version (e.g. `java -version`)
Oracle JDK
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)

### OS version (e.g. `uname -a`)
Linux mmt-ubt-8341 5.4.0-53-generic #59~18.04.1-Ubuntu SMP Wed Oct 21 12:14:56 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

**P.S.: First I thought it was due to the R2DBC MySQL driver(r2dbc-mysql) I was using and I raised it in their github issues, but they suggested me that it isn't on their side but on Netty's side. Issue Link: https://github.com/mirromutth/r2dbc-mysql/issues/153**


Hints:
We tell block hound to permit blocking calls in `SSLEngine.wrap`: https://github.com/netty/netty/blob/4.1/common/src/main/java/io/netty/util/internal/Hidden.java#L108-L112

Does block hound also bark when you use a different `SSLEngine`, like `ReferenceCountedOpenSslEngine`?
@chrisvest Isn't it related to `unwrap` and not `wrap`

```
            builder.allowBlockingCallsInside(
                    "sun.security.ssl.SSLEngineImpl",
                    "unwrap");
```
@violetagg Oh, right. I misread it.
@violetagg are you interested in providing a PR ?
> @violetagg are you interested in providing a PR ?

ok

Patch:
diff --git a/common/src/main/java/io/netty/util/internal/Hidden.java b/common/src/main/java/io/netty/util/internal/Hidden.java
--- a/common/src/main/java/io/netty/util/internal/Hidden.java
+++ b/common/src/main/java/io/netty/util/internal/Hidden.java
@@ -111,6 +111,10 @@ public void applyTo(BlockHound.Builder builder) {
                     "sun.security.ssl.SSLEngineImpl",
                     "unwrap");
 
+            builder.allowBlockingCallsInside(
+                    "sun.security.ssl.SSLEngineImpl",
+                    "wrap");
+
             builder.nonBlockingThreadPredicate(new Function<Predicate<Thread>, Predicate<Thread>>() {
                 @Override
                 public Predicate<Thread> apply(final Predicate<Thread> p) {


Test patch:
diff --git a/transport-blockhound-tests/src/test/java/io/netty/util/internal/NettyBlockHoundIntegrationTest.java b/transport-blockhound-tests/src/test/java/io/netty/util/internal/NettyBlockHoundIntegrationTest.java
--- a/transport-blockhound-tests/src/test/java/io/netty/util/internal/NettyBlockHoundIntegrationTest.java
+++ b/transport-blockhound-tests/src/test/java/io/netty/util/internal/NettyBlockHoundIntegrationTest.java
@@ -20,6 +20,7 @@
 import io.netty.buffer.UnpooledByteBufAllocator;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelFutureListener;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelInboundHandlerAdapter;
 import io.netty.channel.ChannelInitializer;
@@ -63,9 +64,13 @@
 import java.util.concurrent.FutureTask;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
 import java.util.concurrent.locks.ReentrantLock;
 
+import static io.netty.buffer.Unpooled.wrappedBuffer;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.junit.Assume.assumeTrue;
 
@@ -238,6 +243,77 @@ public void testTrustManagerVerifyTLSv13() throws Exception {
         testTrustManagerVerify("TLSv1.3");
     }
 
+    @Test
+    public void testSslHandlerWrapAllowsBlockingCalls() throws Exception {
+        final SslContext sslClientCtx =
+                SslContextBuilder.forClient()
+                                 .trustManager(InsecureTrustManagerFactory.INSTANCE)
+                                 .sslProvider(SslProvider.JDK)
+                                 .build();
+        final SslHandler sslHandler = sslClientCtx.newHandler(UnpooledByteBufAllocator.DEFAULT);
+        final EventLoopGroup group = new NioEventLoopGroup();
+        final CountDownLatch activeLatch = new CountDownLatch(1);
+        final AtomicReference<Throwable> error = new AtomicReference<>();
+
+        Channel sc = null;
+        Channel cc = null;
+        try {
+            sc = new ServerBootstrap()
+                    .group(group)
+                    .channel(NioServerSocketChannel.class)
+                    .childHandler(new ChannelInboundHandlerAdapter())
+                    .bind(new InetSocketAddress(0))
+                    .syncUninterruptibly()
+                    .channel();
+
+            cc = new Bootstrap()
+                    .group(group)
+                    .channel(NioSocketChannel.class)
+                    .handler(new ChannelInitializer<Channel>() {
+
+                        @Override
+                        protected void initChannel(Channel ch) {
+                            ch.pipeline().addLast(sslHandler);
+                            ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
+
+                                @Override
+                                public void channelActive(ChannelHandlerContext ctx) {
+                                    activeLatch.countDown();
+                                }
+
+                                @Override
+                                public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
+                                    if (evt instanceof SslHandshakeCompletionEvent &&
+                                            ((SslHandshakeCompletionEvent) evt).cause() != null) {
+                                        Throwable cause = ((SslHandshakeCompletionEvent) evt).cause();
+                                        cause.printStackTrace();
+                                        error.set(cause);
+                                    }
+                                    ctx.fireUserEventTriggered(evt);
+                                }
+                            });
+                        }
+                    })
+                    .connect(sc.localAddress())
+                    .addListener((ChannelFutureListener) future ->
+                        future.channel().writeAndFlush(wrappedBuffer(new byte [] { 1, 2, 3, 4 })))
+                    .syncUninterruptibly()
+                    .channel();
+
+            assertTrue(activeLatch.await(5, TimeUnit.SECONDS));
+            assertNull(error.get());
+        } finally {
+            if (cc != null) {
+                cc.close().syncUninterruptibly();
+            }
+            if (sc != null) {
+                sc.close().syncUninterruptibly();
+            }
+            group.shutdownGracefully();
+            ReferenceCountUtil.release(sslClientCtx);
+        }
+    }
+
     private static void testTrustManagerVerify(String tlsVersion) throws Exception {
         final SslContext sslClientCtx =
                 SslContextBuilder.forClient()