Skip to content

Conversation

@dfuch
Copy link
Member

@dfuch dfuch commented Nov 7, 2025

Surprisingly if the QUIC handshake fails exceptionally, and -Djdk.httpclient.HttpClient.log=errors is specified, the exception is not logged. This change fixes that.


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-8371471: HttpClient: Log HTTP/3 handshake failures if logging errors is enabled (Sub-task - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28196

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 7, 2025

👋 Welcome back dfuchs! 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 Nov 7, 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 net net-dev@openjdk.org label Nov 7, 2025
@openjdk
Copy link

openjdk bot commented Nov 7, 2025

@dfuch 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.

@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 7, 2025
@mlbridge
Copy link

mlbridge bot commented Nov 7, 2025

Webrevs

@openjdk openjdk bot removed the rfr Pull request is ready for review label Nov 7, 2025
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 7, 2025
// this is a bit fragile and may need to be updated if the
// place where we log the exception from changes.
String expectedClassName = QuicConnectionImpl.class.getName()
+ "$HandshakeFlow";
Copy link
Member

Choose a reason for hiding this comment

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

Would just asserting for the (expected) log message and the presence of stacktrace be enough? Irrespective of which class logs it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Possibly. Let's keep that for now.

final HttpRequest req1 = reqBuilder.copy().GET().build();
System.out.println("Issuing request: " + req1);
final HttpResponse<Void> resp1 = client.send(req1, BodyHandlers.discarding());
Assert.assertEquals(resp1.statusCode(), 200, "unexpected response code for GET request");
Copy link
Member

Choose a reason for hiding this comment

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

Sorry I missed htis in the previous round of review. Shouldn't this line be a fail("Request expected to fail but didn't")?

Copy link
Member Author

@dfuch dfuch Nov 7, 2025

Choose a reason for hiding this comment

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

Oh sorry I meant to just remove this line. I thought it was better to not configure HTTP_3_URI_ONLY on the request in order to trigger the fallback on TCP. So something might actually respond. If something responds then we could get a response. On the other hand this might impacts other tests that might run on the machine...
hmmm... maybe I should fix that.

Copy link
Member Author

Choose a reason for hiding this comment

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

The test now creates a TCP ServerSocket bound to the same port and which will close accepted connections. That should ensure safe fallback on TCP. If the ServerSocket cannot be created (address already in use) then the request will be configured with HTTP3_URI_ONLY to prevent fallback to TCP.

if (Log.errors()) {
Log.logError("%s QUIC handshake failed: %s"
.formatted(logTag(), cause));
Log.logError(cause);
Copy link
Member

Choose a reason for hiding this comment

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

This produces 2 error messages like:

Nov 07, 2025 6:01:57 PM jdk.internal.net.http.quic.QuicConnectionImpl$HandshakeFlow failHandshakeCFs
INFO: ERROR: QuicServerConnection(1) QUIC handshake failed: java.io.IOException: Connection closed by client peer: CRYPTO_ERROR|certificate_unknown certificate_unknown
Nov 07, 2025 6:01:57 PM jdk.internal.net.http.quic.QuicConnectionImpl$HandshakeFlow failHandshakeCFs
INFO: ERROR: java.io.IOException: Connection closed by client peer: CRYPTO_ERROR|certificate_unknown certificate_unknown
java.io.IOException: Connection closed by client peer: CRYPTO_ERROR|certificate_unknown certificate_unknown
	at java.net.http/jdk.internal.net.http.quic.TerminationCause.toReportedCause(TerminationCause.java:129)

Can we remove the duplicate information? Currently there are 2 timestamps, and the exception message is printed 3 times.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have considered this. This would require adding a new logError metod to Log:

    public void logError(String msg, Throwable throwable) {
         ....
    } 

I refrained from doing that because there may be place where we call logError with a message and a throwable and don't expect to see the stack trace. That would require examining all such call sites and cast the Throwable to Object - or add a call to toString() - so that they keep on calling logError(String, Object...).

I'd rather do that in a separate cleanup.

FWIW - what you are seeing in the quoted log are a mix of client traces and server traces: the message on the server talks of the client peer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

net net-dev@openjdk.org rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

3 participants