Class RequestIdSettings
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
- If the request already carries a non-empty id under
attributeKey(idempotent re-entry or a parent filter), that value is honored unchanged. - Otherwise, if an incoming
X-Request-Idheader is present, it is sanitized and length-capped toRequestIdConstants.MAX_LEN; the sanitized value is honored when it is non-empty, not truncated, and accepted byvalidator. - 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
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic RequestIdSettings.Buildercreate()Creates a new builder.Returns the servlet-request attribute key under which the resolved id is stashed.Returns the supplier used to mint a fresh id when none is honored from the request.Returns the predicate applied to a sanitized incoming id to decide whether to honor it.
-
Constructor Details
-
RequestIdSettings
Constructor.- Parameters:
b- The builder configuring these settings. Must not benull .
-
-
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 .
-