Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed reliance on exception to shutdown non persistent connections #12213

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,11 @@ public void onFillable()
{
while (getEndPoint().isOpen())
{
if (LOG.isDebugEnabled())
LOG.debug("onFillable fill and parse {} {} {}", this, _httpChannel, _retainableByteBuffer);

// Fill the request buffer (if needed).
int filled = fillRequestBuffer();
if (LOG.isDebugEnabled())
LOG.debug("onFillable filled {} {} {} {}", filled, this, _httpChannel, _retainableByteBuffer);

if (filled < 0 && getEndPoint().isOutputShutdown())
close();

Expand Down Expand Up @@ -1523,12 +1523,17 @@ public void succeeded()
return;
}

// as this is not an upgrade, we can shutdown the output if we know we are not persistent
gregw marked this conversation as resolved.
Show resolved Hide resolved
if (_sendCallback._shutdownOut)
getEndPoint().shutdownOutput();

_httpChannel.recycle();


// If we are still expecting 100 Continue and no content was read, then
// close the parser so that below it seeks EOF, not the next request.
gregw marked this conversation as resolved.
Show resolved Hide resolved
if (_expects100Continue)
{
// No content was read, and no 100 Continue response was sent.
// Close the parser so that below it seeks EOF, not the next request.
_expects100Continue = false;
_parser.close();
}
Expand All @@ -1541,7 +1546,6 @@ public void succeeded()
else
_parser.close();
}

_generator.reset();

// Can the onFillable thread continue processing
Expand All @@ -1552,9 +1556,6 @@ public void succeeded()
if (LOG.isDebugEnabled())
LOG.debug("non-current completion {}", this);

if (_sendCallback._shutdownOut)
getEndPoint().shutdownOutput();

// If we are looking for the next request
if (_parser.isStart())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public boolean handle(Request request, Response response, Callback callback)
}
});

try (Socket client = newSocket(_serverURI.getHost(), _serverURI.getPort()))
try (StacklessLogging ignored = new StacklessLogging(Response.class); Socket client = newSocket(_serverURI.getHost(), _serverURI.getPort()))
{
OutputStream os = client.getOutputStream();

Expand Down Expand Up @@ -233,7 +233,7 @@ public boolean handle(Request request, Response response, Callback callback) thr
}
});

try (Socket client = newSocket(_serverURI.getHost(), _serverURI.getPort()))
try (StacklessLogging ignored = new StacklessLogging(Response.class); Socket client = newSocket(_serverURI.getHost(), _serverURI.getPort()))
{
OutputStream os = client.getOutputStream();

Expand Down Expand Up @@ -1669,12 +1669,10 @@ public void testWriteBodyAfterNoBodyResponse() throws Exception
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));

String line = in.readLine();
System.err.println(line);
assertThat(line, containsString(" 304 "));
while (true)
{
line = in.readLine();
System.err.println(line);
if (line == null)
throw new EOFException();
if (line.length() == 0)
Expand All @@ -1685,7 +1683,6 @@ public void testWriteBodyAfterNoBodyResponse() throws Exception
assertThat(line, not(containsString("Transfer-Encoding")));
}

System.err.println("---");
line = in.readLine();
assertThat(line, containsString(" 304 "));
while (true)
Expand Down
Loading