diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java index b1f3d322aebb..3b66b4d305f5 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java @@ -671,7 +671,6 @@ public int fill(ByteBuffer buffer) throws IOException else { appIn = _decryptedInput; - BufferUtil.compact(_encryptedInput); } // Let's try reading some encrypted data... even if we have some already. @@ -729,12 +728,18 @@ public int fill(ByteBuffer buffer) throws IOException return filled = -1; case BUFFER_UNDERFLOW: + // Continue if we can compact? + if (BufferUtil.compact(_encryptedInput)) + continue; + + // Are we out of space? if (BufferUtil.space(_encryptedInput) == 0) { BufferUtil.clear(_encryptedInput); throw new SSLHandshakeException("Encrypted buffer max length exceeded"); } + // if we just filled some if (netFilled > 0) continue; // try filling some more