RFR: 8376031: HttpsURLConnection.getServerCertificates() throws "java.lang.IllegalStateException: connection not yet open" for the HEAD method [v2]

Daniel Fuchs dfuchs at openjdk.org
Tue Feb 3 16:36:09 UTC 2026


> 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`.

Daniel Fuchs has updated the pull request incrementally with one additional commit since the last revision:

  Review feedback

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/29489/files
  - new: https://git.openjdk.org/jdk/pull/29489/files/1c0e3d93..d962cb8e

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=29489&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=29489&range=00-01

  Stats: 18 lines in 3 files changed: 9 ins; 4 del; 5 mod
  Patch: https://git.openjdk.org/jdk/pull/29489.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29489/head:pull/29489

PR: https://git.openjdk.org/jdk/pull/29489


More information about the net-dev mailing list