review comments

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
Ludovic Orban 2021-05-19 15:53:49 +02:00
parent 6ed64e1e65
commit 1d5d8071ba
2 changed files with 7 additions and 6 deletions

View File

@ -55,7 +55,8 @@ public class HttpInput extends ServletInputStream implements Runnable
public void recycle() public void recycle()
{ {
reopen(); if (LOG.isDebugEnabled())
LOG.debug("recycle {}", this);
} }
public void reopen() public void reopen()
@ -63,7 +64,7 @@ public class HttpInput extends ServletInputStream implements Runnable
try (AutoLock lock = _contentProducer.lock()) try (AutoLock lock = _contentProducer.lock())
{ {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("recycle/reopen {}", this); LOG.debug("reopen {}", this);
_blockingContentProducer.recycle(); _blockingContentProducer.recycle();
_contentProducer = _blockingContentProducer; _contentProducer = _blockingContentProducer;
_consumedEof = false; _consumedEof = false;

View File

@ -56,12 +56,13 @@ public class RequestReaderTest extends AbstractTest<TransportScenario>
if (b == -1) if (b == -1)
break; break;
} }
// Paranoid check.
assertThat(br.read(), is(-1));
baseRequest.setHandled(true); baseRequest.setHandled(true);
} }
}, client -> {}); }, client -> {});
ContentResponse response1 = scenario.client.newRequest("localhost", scenario.server.getURI().getPort()) ContentResponse response1 = scenario.client.newRequest(scenario.newURI())
.scheme(scenario.server.getURI().getScheme())
.method("POST") .method("POST")
.timeout(5, TimeUnit.SECONDS) .timeout(5, TimeUnit.SECONDS)
.body(new BytesRequestContent(new byte[512])) .body(new BytesRequestContent(new byte[512]))
@ -69,8 +70,7 @@ public class RequestReaderTest extends AbstractTest<TransportScenario>
assertThat(response1.getStatus(), is(HttpStatus.OK_200)); assertThat(response1.getStatus(), is(HttpStatus.OK_200));
// Send a 2nd request to make sure recycling works. // Send a 2nd request to make sure recycling works.
ContentResponse response2 = scenario.client.newRequest("localhost", scenario.server.getURI().getPort()) ContentResponse response2 = scenario.client.newRequest(scenario.newURI())
.scheme(scenario.server.getURI().getScheme())
.method("POST") .method("POST")
.timeout(5, TimeUnit.SECONDS) .timeout(5, TimeUnit.SECONDS)
.body(new BytesRequestContent(new byte[512])) .body(new BytesRequestContent(new byte[512]))