Issue #5368 - warn if MessageInputStream closed without fully consuming

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2020-10-06 17:43:58 +11:00
parent 941ffcead7
commit 6c94ef5848
1 changed files with 13 additions and 4 deletions

View File

@ -87,6 +87,7 @@ public class MessageInputStream extends InputStream implements MessageAppender
switch (state)
{
case CLOSED:
LOG.warn("Received content after InputStream closed");
return;
case RESUMED:
@ -118,9 +119,11 @@ public class MessageInputStream extends InputStream implements MessageAppender
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);
}
}
@ -156,11 +159,17 @@ public class MessageInputStream extends InputStream implements MessageAppender
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)