On Wed, 11 Nov 2026 16:13:34 GMT, Roland Mesde <[email protected]> wrote:

>> This PR makes the HTTP2 client use MalformedFrame.errorStream. A PRIORITY 
>> frame with an invalid length resets its stream (based on RFC 9113) instead 
>> of closing the connection. In addition, invalid ALTSVC frames are now 
>> skipped, and the unused variables (prepareToRelease, slicedToDataFrame) and 
>> method (frameProcessed) were removed from FramesDecoder.
>> 
>> Low risk - affects handling of malformed PRIORITY and ALTSVC frames.
>> 
>> Ran related tests on linux-x64, linux-aarch64, macos-aarch64 and windows-x64:
>> 
>> make test TEST=test/jdk/java/net/httpclient
>> 
>> Results (updated 11/11/2026):
>> 
>> [windows-x64-specific-test.log](https://github.com/user-attachments/files/34702755/windows-x64-specific-test.log)
>> [macos-aarch64-specific-test.log](https://github.com/user-attachments/files/34702756/macos-aarch64-specific-test.log)
>> [linux-x64-specific-test.log](https://github.com/user-attachments/files/34702757/linux-x64-specific-test.log)
>> [linux-aarch64-specific-test.log](https://github.com/user-attachments/files/34702758/linux-aarch64-specific-test.log)
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Roland Mesde has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Remove unused prepareToRelease, slicedToDataFrame and frameProcessed() from 
> FramesDecoder

src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java line 
947:

> 945:             Log.logError(malformedFrame.getMessage());
> 946:             int errorStream = malformedFrame.getErrorStream();
> 947:             if (errorStream == 0) {

use the new isConnectionError getter here?

src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java line 
957:

> 955:                         debug.log(() -> "Reset stream " + errorStream + 
> ": "
> 956:                                 + malformedFrame.getMessage());
> 957:                     stream.onProtocolError(new ProtocolException(

why did you replace `resetStream` with the `isTerminalState` / 
`onProtocolError` combo?

src/java.net.http/share/classes/jdk/internal/net/http/frame/FramesDecoder.java 
line 287:

> 285:                 extractedBuf = 
> Utils.sliceWithLimitedCapacity(currentBuffer, extract)
> 286:                                     .asReadOnlyBuffer();
> 287:                 slicedToDataFrame = true;

since you're already cleaning it up, get rid of the entire if/else block and 
the HPACK comment below, and keep just the extractedBuf assignment.

src/java.net.http/share/classes/jdk/internal/net/http/frame/FramesDecoder.java 
line 553:

> 551:     private Http2Frame parseAltSvcFrame(int frameLength, int 
> frameStreamid, int frameFlags) {
> 552:         if (frameLength < 2) {
> 553:             skipBytes(frameLength);

no need to skipBytes if you're returning a connection-closing malformedFrame.

src/java.net.http/share/classes/jdk/internal/net/http/frame/FramesDecoder.java 
line 559:

> 557:         var len = getShort();
> 558:         if (len > frameLength - 2) {
> 559:             skipBytes(frameLength - 2);

same here

src/java.net.http/share/classes/jdk/internal/net/http/frame/MalformedFrame.java 
line 73:

> 71:     }
> 72: 
> 73:     public int getErrorStream() {

could you drop the errorStream field and getter and use the streamId inherited 
field instead? Keeping two fields (one unused) for the same information (stream 
id) was the root cause of this bug, after all.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/33824#discussion_r4550353558
PR Review Comment: https://git.openjdk.org/jdk/pull/33824#discussion_r4550583282
PR Review Comment: https://git.openjdk.org/jdk/pull/33824#discussion_r4550304389
PR Review Comment: https://git.openjdk.org/jdk/pull/33824#discussion_r4550320433
PR Review Comment: https://git.openjdk.org/jdk/pull/33824#discussion_r4550321947
PR Review Comment: https://git.openjdk.org/jdk/pull/33824#discussion_r4550344466

Reply via email to