Class OutboundHeaderContext

java.lang.Object
com.svenruppert.jsentinel.credential.propagation.OutboundHeaderContext

@ExperimentalJSentinelApi("V00.74 token propagation; stable promotion staged for V00.76") public final class OutboundHeaderContext extends Object
Thread-local bridge between the V00.74 wrapper (runtime PropagatingProxy or compile-time <Type>Propagating) and the application's HTTP client. The wrapper binds a header, runs the delegate, and clear()s in a finally. The HTTP client reads current() just before sending and applies it on the request.

Two-line interceptor pattern (JDK HttpClient):

OutboundHeaderContext.current()
    .ifPresent(h -> requestBuilder.header(h.name(), h.value()));

Single slot per thread, never inherited. Nested binds raise — the wrapper resets in finally, so a second bind without an intervening clear is a programming error.

Since:
00.74.00
  • Method Details

    • bind

      public static void bind(HeaderValue value)
      Bind a header to the current thread.
      Parameters:
      value - the header to bind; non-null
      Throws:
      IllegalStateException - if the slot is already bound — a second bind without an intervening clear() is a programming error
    • current

      public static Optional<HeaderValue> current()
      Returns:
      the currently bound header, or empty
    • clear

      public static void clear()
      Reset the slot. Idempotent — repeated calls are no-ops.