Skip to content

Commit

Permalink
SslHandler#handlerRemoved0() shouldn't care about the SSLEngine being…
Browse files Browse the repository at this point in the history
… a specific type but only if it's ReferenceCounted

Motivation

SslHandler should release any type of SSLEngine if it implements the ReferenceCounted interface

Modifications

Change condition to check for ReferenceCounted interface

Result

Better use of interfaces
  • Loading branch information
Roger Kapsi authored and normanmaurer committed May 19, 2017
1 parent d768c5e commit 915bf5f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions handler/src/main/java/io/netty/handler/ssl/SslHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import io.netty.channel.PendingWriteQueue;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.UnsupportedMessageTypeException;
import io.netty.util.ReferenceCounted;
import io.netty.util.concurrent.DefaultPromise;
import io.netty.util.concurrent.EventExecutor;
import io.netty.util.concurrent.Future;
Expand Down Expand Up @@ -580,8 +581,8 @@ public void handlerRemoved0(ChannelHandlerContext ctx) throws Exception {
// Check if queue is not empty first because create a new ChannelException is expensive
pendingUnencryptedWrites.removeAndFailAll(new ChannelException("Pending write on removal of SslHandler"));
}
if (engine instanceof ReferenceCountedOpenSslEngine) {
((ReferenceCountedOpenSslEngine) engine).release();
if (engine instanceof ReferenceCounted) {
((ReferenceCounted) engine).release();
}
}

Expand Down

0 comments on commit 915bf5f

Please sign in to comment.