#10543 make sure HttpConnection always releases its retainable buffer when needed

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
Ludovic Orban 2023-09-26 12:44:57 +02:00
parent e290ff9561
commit aab665d7e1
1 changed files with 11 additions and 5 deletions

View File

@ -586,19 +586,20 @@ public class HttpConnection extends AbstractConnection implements Runnable, Writ
if (filled == 0) // Do a retry on fill 0 (optimization for SSL connections)
filled = getEndPoint().fill(requestBuffer);
if (LOG.isDebugEnabled())
LOG.debug("{} filled {} {}", this, filled, _retainableByteBuffer);
if (filled > 0)
{
bytesIn.add(filled);
}
else if (filled < 0)
else
{
if (filled < 0)
_parser.atEOF();
releaseRequestBuffer();
_parser.atEOF();
}
if (LOG.isDebugEnabled())
LOG.debug("{} filled {} {}", this, filled, _retainableByteBuffer);
return filled;
}
catch (IOException e)
@ -606,6 +607,11 @@ public class HttpConnection extends AbstractConnection implements Runnable, Writ
if (LOG.isDebugEnabled())
LOG.debug("Unable to fill from endpoint {}", getEndPoint(), e);
_parser.atEOF();
if (_retainableByteBuffer != null)
{
_retainableByteBuffer.clear();
releaseRequestBuffer();
}
return -1;
}
}