On Thu, 29 Jan 2026 15:32:50 GMT, Daniel Fuchs <[email protected]> wrote:
> The issue here is that `HttpURLConnection` is automatically disconnected
> (`HttpClient` is set to `null`, `connected` is set to `false`) when a
> response with no response body bytes is received. This happens before a fake
> empty body input stream is returned to the user. That behaviour also occurs
> with any method for which `content-length: 0` is returned (GET, POST, custom,
> anything), and with any status code (204, 304) for which there is no body.
>
> In this case, the proposed fix is to store the `SSLSession` in the
> `AbstractDelegateHttpsURLConnection` subclass until such a time where
> `disconnect()` is explicitely closed. Information pertaining to SSL, such as
> server certificates, can be extracted from the saved `SSLSession`.
test/jdk/sun/net/www/protocol/https/HttpsURLConnection/GetServerCertificates.java
line 140:
> 138: if (!"GET".equals(method)) {
> 139: uc.setRequestMethod(method);
> 140: }
Is the use of these conditionals on `GET` intentional? From what I can see, we
could just call `uc.setRequestMethod(method);` without the `if` blocks. It's OK
to keep it in this manner if you prefer doing so.
test/jdk/sun/net/www/protocol/https/HttpsURLConnection/GetServerCertificates.java
line 151:
> 149: .formatted(code, resp));
> 150:
> 151: uc.getServerCertificates();
Here and a few other places in this test, should we assert that this returns
non-null certificates?
test/jdk/sun/net/www/protocol/https/HttpsURLConnection/GetServerCertificates.java
line 295:
> 293: try {test(args);} catch (Throwable t) {unexpected(t);}
> 294: System.out.printf("%nPassed = %d, failed = %d%n%n", passed,
> failed);
> 295: if (failed > 0) throw new AssertionError("Some tests failed");}
I realize this was the old style of tests we have in some parts of the JDK, but
maybe for this new test we can simplify this to just something like:
public static void main(String[] args) throws Exception {
tests(args);
}
and then let any `check()` calls throw and propagate an exception instead of
counting the number of pass/fail?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29489#discussion_r2751125961
PR Review Comment: https://git.openjdk.org/jdk/pull/29489#discussion_r2751126351
PR Review Comment: https://git.openjdk.org/jdk/pull/29489#discussion_r2751124878