From 07266cbd0b135b1fbcc6a176c357f9d0324f7a8d Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Sun, 20 Apr 2014 17:20:00 +0900 Subject: [PATCH] Better names for SslHandler.unwrap*() methods Motivation: The names of SslHandler.unwrap*() methods are somewhat ambiguous. Modifications: - Rename unwrap() to unwrapMultiple() and unwrapNonApp() - Rename unwrap0() to unwrapSingle() Result: Readability --- .../jboss/netty/handler/ssl/SslHandler.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/jboss/netty/handler/ssl/SslHandler.java b/src/main/java/org/jboss/netty/handler/ssl/SslHandler.java index 29fda15300..c2af2abd55 100644 --- a/src/main/java/org/jboss/netty/handler/ssl/SslHandler.java +++ b/src/main/java/org/jboss/netty/handler/ssl/SslHandler.java @@ -918,7 +918,7 @@ public class SslHandler extends FrameDecoder // // See https://github.com/netty/netty/issues/1534 assert recordLengths != null; - unwrapped = unwrap(ctx, channel, in, totalLength, recordLengths, nRecords); + unwrapped = unwrapMultiple(ctx, channel, in, totalLength, recordLengths, nRecords); } if (nonSslRecord) { @@ -1227,7 +1227,17 @@ public class SslHandler extends FrameDecoder return future; } - private ChannelBuffer unwrap( + /** + * Calls {@link SSLEngine#unwrap(ByteBuffer, ByteBuffer)} with an empty buffer to handle handshakes, etc. + */ + private void unwrapNonAppData(ChannelHandlerContext ctx, Channel channel) throws SSLException { + unwrapSingle(ctx, channel, ChannelBuffers.EMPTY_BUFFER, EMPTY_BUFFER, null, -1); + } + + /** + * Unwraps multiple inbound SSL records. + */ + private ChannelBuffer unwrapMultiple( ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, int totalLength, int[] recordLengths, int nRecords) throws SSLException { @@ -1236,18 +1246,17 @@ public class SslHandler extends FrameDecoder for (int i = 0; i < nRecords; i ++) { inNetBuf.limit(inNetBuf.position() + recordLengths[i]); - frame = unwrap0(ctx, channel, buffer, inNetBuf, frame, totalLength); + frame = unwrapSingle(ctx, channel, buffer, inNetBuf, frame, totalLength); assert !inNetBuf.hasRemaining(); } return frame; } - private void unwrapNonAppData(ChannelHandlerContext ctx, Channel channel) throws SSLException { - unwrap0(ctx, channel, ChannelBuffers.EMPTY_BUFFER, EMPTY_BUFFER, null, -1); - } - - private ChannelBuffer unwrap0( + /** + * Unwraps a single SSL record. + */ + private ChannelBuffer unwrapSingle( ChannelHandlerContext ctx, Channel channel, ChannelBuffer nettyInNetBuf, ByteBuffer nioInNetBuf, ChannelBuffer nettyOutAppBuf, int initialNettyOutAppBufCapacity) throws SSLException {