Class Http2GoAwayEmitter

java.lang.Object
org.mockserver.netty.unification.Http2GoAwayEmitter

public final class Http2GoAwayEmitter extends Object
Emits an HTTP/2 GOAWAY frame on the connection carrying ctx so the client is told to stop opening new streams and drain — the graceful "this connection is going away" signal a server sends before a shutdown / preemption. In-flight streams are allowed to complete; GOAWAY does not reset them.

GOAWAY is a connection-level frame, so it is always written on the connection channel's pipeline where the Http2ConnectionHandler lives, regardless of which channel emit was called from:

  • On the connection-level (default) HTTP/2 pipeline the handler is on ctx's own pipeline (resolved with the same lookup pattern as HttpErrorActionHandler.resetHttp2Streamctx.pipeline().context(Http2ConnectionHandler.class)), so it works whether called from a child handler or the connection handler's own context.
  • On the multiplex pipeline (per-stream child channels, used for gRPC bidi streaming) the request handlers run on a stream child channel whose pipeline has no Http2ConnectionHandler — the Http2FrameCodec (which extends Http2ConnectionHandler) lives on the parent connection channel. When the local pipeline has no connection handler, emit walks up to ctx.channel().parent().pipeline() and writes the GOAWAY there.

HTTP/1.1 has no GOAWAY concept and no Http2ConnectionHandler on any pipeline, so emit returns false and callers degrade to Connection: close + 503 instead.

  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    emit(io.netty.channel.ChannelHandlerContext ctx, long lastStreamId, long errorCode)
    Emit a GOAWAY on the connection carrying ctx, whether ctx is on a connection-level HTTP/2 pipeline or a multiplex stream child channel.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • emit

      public static boolean emit(io.netty.channel.ChannelHandlerContext ctx, long lastStreamId, long errorCode)
      Emit a GOAWAY on the connection carrying ctx, whether ctx is on a connection-level HTTP/2 pipeline or a multiplex stream child channel.
      Parameters:
      ctx - a context on the HTTP/2 channel's pipeline — either the connection channel or a per-stream child channel
      lastStreamId - the lastStreamId to advertise; when negative the connection handler's current last-stream-id is used (passing the max stream id so the handler clamps to the connection's actual last-processed stream)
      errorCode - the HTTP/2 error code (0 = NO_ERROR, the graceful-shutdown code)
      Returns:
      true if a GOAWAY was written (an HTTP/2 connection handler was found on this pipeline or the parent connection channel's pipeline), false otherwise (e.g. HTTP/1.1, or no HTTP/2 connection handler anywhere)