Skip to content

Commit

Permalink
Issue #5368 - warn if MessageInputStream closed without fully consuming
Browse files Browse the repository at this point in the history
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
  • Loading branch information
lachlan-roberts committed Oct 6, 2020
1 parent 941ffce commit 6c94ef5
Showing 1 changed file with 13 additions and 4 deletions.
Expand Up @@ -87,6 +87,7 @@ public void appendFrame(ByteBuffer framePayload, boolean fin) throws IOException
switch (state)
{
case CLOSED:
LOG.warn("Received content after InputStream closed");
return;

case RESUMED:
Expand Down Expand Up @@ -118,9 +119,11 @@ public void close()
if (state == State.CLOSED)
return;

if (!buffers.isEmpty() || (activeBuffer != null && activeBuffer.hasRemaining()))
LOG.warn("InputStream closed without fully consuming content");

state = State.CLOSED;
buffers.clear();
buffers.offer(EOF);
}
}

Expand Down Expand Up @@ -156,11 +159,17 @@ public void handlerComplete()
SuspendToken resume;
synchronized (this)
{
state = State.CLOSED;
if (state != State.CLOSED)
{
if (!buffers.isEmpty() || (activeBuffer != null && activeBuffer.hasRemaining()))
LOG.warn("InputStream closed without fully consuming content");

state = State.CLOSED;
buffers.clear();
}

resume = suspendToken;
suspendToken = null;
buffers.clear();
buffers.offer(EOF);
}

if (resume != null)
Expand Down

0 comments on commit 6c94ef5

Please sign in to comment.