Class Http2StreamException

All Implemented Interfaces:
Serializable

public final class Http2StreamException extends RuntimeException
A stream-level HTTP/2 error, scoped to one stream id. Results in an RST_STREAM frame for streamId() with errorCode(); the connection and every other stream on it are unaffected. Compare Http2Exception, whose scope is the whole connection.

Deliberately does not extend IOException, for the same reason as Http2Exception: the connection loop must be able to distinguish "we decided to reject this stream" from "the socket failed" by catching unrelated exception types.

Why this allocates, unlike Http2Exception's singletons

Every instance carries a distinct streamId(), so it cannot be a shared singleton the exempts error paths. The scenario where this matters most — a peer opening and resetting thousands of streams per second (the Rapid Reset pattern, CVE-2023-44487) — is bounded by that can force RST_STREAM generation fast enough for GC pressure to matter has already tripped Http2Limits.MAX_RESET_STREAMS_PER_INTERVAL and the connection is being torn down anyway.

Stack trace capture is disabled for the same cost reason as Http2Exception.

See Also:
  • Constructor Details

    • Http2StreamException

      public Http2StreamException(int streamId, Http2ErrorCode errorCode, String message)
  • Method Details

    • streamId

      public int streamId()
      The id of the stream this error terminates.
    • errorCode

      public Http2ErrorCode errorCode()
      The RFC 9113 §7 error code to send in the RST_STREAM frame.