diff --git a/src/main/java/com/rabbitmq/client/impl/nio/SslEngineHelper.java b/src/main/java/com/rabbitmq/client/impl/nio/SslEngineHelper.java index d9a5b17105..442359c78b 100644 --- a/src/main/java/com/rabbitmq/client/impl/nio/SslEngineHelper.java +++ b/src/main/java/com/rabbitmq/client/impl/nio/SslEngineHelper.java @@ -110,6 +110,7 @@ private static SSLEngineResult.HandshakeStatus unwrap(ByteBuffer cipherIn, ByteB SSLEngineResult unwrapResult; do { int positionBeforeUnwrapping = cipherIn.position(); + LOGGER.debug("Before unwrapping cipherIn is {}, with {} remaining byte(s)", cipherIn, cipherIn.remaining()); unwrapResult = sslEngine.unwrap(cipherIn, plainIn); LOGGER.debug("SSL engine result is {} after unwrapping", unwrapResult); status = unwrapResult.getStatus(); @@ -118,14 +119,7 @@ private static SSLEngineResult.HandshakeStatus unwrap(ByteBuffer cipherIn, ByteB plainIn.clear(); if (unwrapResult.getHandshakeStatus() == NEED_TASK) { handshakeStatus = runDelegatedTasks(sslEngine); - int newPosition = positionBeforeUnwrapping + unwrapResult.bytesConsumed(); - if (newPosition == cipherIn.limit()) { - LOGGER.debug("Clearing cipherIn because all bytes have been read and unwrapped"); - cipherIn.clear(); - } else { - LOGGER.debug("Setting cipherIn position to {} (limit is {})", newPosition, cipherIn.limit()); - cipherIn.position(positionBeforeUnwrapping + unwrapResult.bytesConsumed()); - } + cipherIn.position(positionBeforeUnwrapping + unwrapResult.bytesConsumed()); } else { handshakeStatus = unwrapResult.getHandshakeStatus(); }