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 3d8f1414e25b..905ab7b592b1 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 @@ -879,6 +879,9 @@ public synchronized boolean flush(ByteBuffer... appOuts) throws IOException } return allConsumed; + case BUFFER_UNDERFLOW: + throw new IllegalStateException(); + case BUFFER_OVERFLOW: { // It's possible that SSLSession.packetBufferSize has been expanded @@ -892,12 +895,13 @@ public synchronized boolean flush(ByteBuffer... appOuts) throws IOException releaseEncryptedOutputBuffer(); continue; } - throw new IllegalStateException("Unexpected wrap result " + wrapResultStatus); + if (BufferUtil.isEmpty(_encryptedOutput)) + { + throw new IllegalStateException("Unexpected wrap result " + wrapResultStatus); + } + // fall-through default case to flush() } - case BUFFER_UNDERFLOW: - throw new IllegalStateException(); - default: if (DEBUG) LOG.debug("{} {} {}", this, wrapResultStatus, BufferUtil.toDetailString(_encryptedOutput));