From e96eab52a1d8d33087b24b4ffd675bc050981987 Mon Sep 17 00:00:00 2001 From: Bosanac Dejan Date: Mon, 30 Apr 2012 14:56:09 +0000 Subject: [PATCH] https://issues.apache.org/jira/browse/AMQ-3819 - handle BUFFER_UNDERFLOW case git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1332230 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/transport/nio/NIOSSLTransport.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/nio/NIOSSLTransport.java b/activemq-core/src/main/java/org/apache/activemq/transport/nio/NIOSSLTransport.java index 053403839a..b9baeb38b7 100644 --- a/activemq-core/src/main/java/org/apache/activemq/transport/nio/NIOSSLTransport.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/nio/NIOSSLTransport.java @@ -135,7 +135,11 @@ public class NIOSSLTransport extends NIOTransport { while(true) { if (!plain.hasRemaining()) { - plain.clear(); + if (status == SSLEngineResult.Status.OK && handshakeStatus != SSLEngineResult.HandshakeStatus.NEED_UNWRAP) { + plain.clear(); + } else { + plain.compact(); + } int readCount = secureRead(plain); @@ -150,7 +154,9 @@ public class NIOSSLTransport extends NIOTransport { } } - processCommand(plain); + if (status == SSLEngineResult.Status.OK && handshakeStatus != SSLEngineResult.HandshakeStatus.NEED_UNWRAP) { + processCommand(plain); + } } } catch (IOException e) { @@ -192,7 +198,7 @@ public class NIOSSLTransport extends NIOTransport { protected int secureRead(ByteBuffer plain) throws Exception { - if (!(inputBuffer.position() != 0 && inputBuffer.hasRemaining())) { + if (!(inputBuffer.position() != 0 && inputBuffer.hasRemaining()) || status == SSLEngineResult.Status.BUFFER_UNDERFLOW) { int bytesRead = channel.read(inputBuffer); if (bytesRead == -1) {