Class RequestIdSettings

java.lang.Object
org.apache.juneau.rest.server.RequestIdSettings

public class RequestIdSettings extends Object
Configuration for the always-on request-id correlation resolver run at RestSession build time.

This is the public write-surface for tuning how the framework mints or honors the X-Request-Id correlation id for every request — including 404 / early-error paths that never reach a @RestStartCall hook. Register a configured instance as a bean, or return one from a @Bean factory method on the resource; the resolver picks it up via RestContext.getRequestIdSettings().

Resolution behavior
  1. If the request already carries a non-empty id under attributeKey (idempotent re-entry or a parent filter), that value is honored unchanged.
  2. Otherwise, if an incoming X-Request-Id header is present, it is sanitized and length-capped to RequestIdConstants.MAX_LEN; the sanitized value is honored when it is non-empty, not truncated, and accepted by validator.
  3. Otherwise a fresh id is minted via idSupplier.
Default validator — sanitize-and-accept

Unlike a reject-and-remint regex, the default validator accepts any candidate that survives sanitization within the length cap. The sanitizer already neutralizes CR/LF/control-character header-injection payloads (escaping them to inert, ASCII-safe \\uXXXX), so the default honors a cleaned form rather than discarding a slightly-dirty id. Supply a stricter validator (e.g. UUID-only) to opt into reject-and-remint.

See Also:
Since:
10.0.0
  • Constructor Details

  • Method Details

    • create

      Creates a new builder.
      Returns:
      A new builder.
    • getValidator

      Returns the predicate applied to a sanitized incoming id to decide whether to honor it.
      Returns:
      The validator predicate. Never null.
    • getAttributeKey

      Returns the servlet-request attribute key under which the resolved id is stashed.
      Returns:
      The attribute key. Never null.
    • getIdSupplier

      Returns the supplier used to mint a fresh id when none is honored from the request.
      Returns:
      The id supplier. Never null.