Skip to content

8352502: Response message is null if expect 100 assertion fails with non 100 #25999

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DarraghClarke
Copy link
Contributor

@DarraghClarke DarraghClarke commented Jun 26, 2025

Currently if a request has set Expect-Continue and receives a non 100 response the responseMessage wouldn't be set.

This PR sets responseMessage, it also updates getResponseMessage to check if the message has already been set. This should match the way that responseCode is currently handled.

I also added a test to cover some possible responses.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8352502: Response message is null if expect 100 assertion fails with non 100 (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25999/head:pull/25999
$ git checkout pull/25999

Update a local copy of the PR:
$ git checkout pull/25999
$ git pull https://git.openjdk.org/jdk.git pull/25999/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25999

View PR using the GUI difftool:
$ git pr show -t 25999

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25999.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 26, 2025

👋 Welcome back dclarke! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jun 26, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 26, 2025
@openjdk
Copy link

openjdk bot commented Jun 26, 2025

@DarraghClarke The following label will be automatically applied to this pull request:

  • net

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@mlbridge
Copy link

mlbridge bot commented Jun 26, 2025

Webrevs

} catch (SocketException e) {
// ignore
} catch (IOException e) {
throw new RuntimeException(e);
Copy link
Member

@dfuch dfuch Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exception will be swallowed, it will have no effect.

Comment on lines +157 to +159
} catch (Exception ex) {
// swallow the exception
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DarraghClarke - I am curious, is this catch clause necessary? If it is maybe you could improve the comment here to explain why it is necessary.

Runnable runnable = () -> {
while (!control.stop) {
try {
Socket socket = control.serverSocket.accept();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this socket will not be closed... I understand closing it here might cause a reset...
Is that the reason for the catch clause on the client side?

public void test(int expectedCode, String statusLine, String expectedMessage) throws Exception {
String body = "Testing: " + expectedCode;
Control control = this.control;
control.statusLine = statusLine + "\r\n\r\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you add Content-Length: 0 here?

String.format("Expected %s response, instead received %s", expectedCode, responseCode));
assertTrue(expectedMessage.equals(responseMessage),
String.format("Expected Response Message %s, instead received %s",
expectedMessage, responseMessage));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe the connection should be explicitely closed at the end.
maybe the accepted socket should be added to Control and closed here too?


//send a wrong response
outputStream.write(control.statusLine.getBytes());
outputStream.flush();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you added Content-Length: 0 the the status line (which should be better called response BTW) then you should be able to at least call socket.shutdownOutput() here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
net [email protected] rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

2 participants