Class ParsingErrorHandler

java.lang.Object
org.apache.pekko.http.ParsingErrorHandler
Direct Known Subclasses:
ContextReportingParsingErrorHandler$, DefaultParsingErrorHandler$, TestParsingErrorHandler$

public abstract class ParsingErrorHandler extends Object
Produces the response to a request that failed to parse. Selected by the pekko.http.server.parsing-error-handler setting.

This is also the earliest public symbol that observes a rejected request, so it is what observability tooling attaches to: the OpenTelemetry Java agent instruments handle to emit a span for a request that never reaches the route handler (open-telemetry/opentelemetry-java-instrumentation#5139).

  • Constructor Details

    • ParsingErrorHandler

      public ParsingErrorHandler()
  • Method Details

    • handle

      public abstract HttpResponse handle(StatusCode status, ErrorInfo error, org.apache.pekko.event.LoggingAdapter log, ServerSettings settings)
    • handle

      public HttpResponse handle(StatusCode status, ErrorInfo error, org.apache.pekko.event.LoggingAdapter log, ServerSettings settings, IllegalRequestContext context)
      Called by the server for a request that failed to parse, with what is known about that request.

      The default implementation ignores context and delegates to the four-argument handle, so existing handlers keep working unchanged; override this method instead to make use of the context. The parameter is still worth passing for a handler that does not read it, because the arguments of this method are visible to anything instrumenting it: the OpenTelemetry Java agent has to name the span it emits for a rejected request HTTP and report neither http.request.method nor url.path, since the four-argument signature describes only the failure and never the request that caused it. See {@link https://github.com/apache/pekko-http/issues/1245}.

      Note that DefaultParsingErrorHandler deliberately keeps implementing the four-argument method rather than this one, so that advice matching that signature keeps firing.

      Parameters:
      status - (undocumented)
      error - (undocumented)
      log - (undocumented)
      settings - (undocumented)
      context - (undocumented)
      Returns:
      (undocumented)
      Since:
      2.0.0