Class RemoteUrlPolicyState

java.lang.Object
org.apache.juneau.rest.client.classic.remote.RemoteUrlPolicyState

public final class RemoteUrlPolicyState extends Object
Marks the current thread as executing an SSRF-guard-active @Remote call, for the duration of one blocking RestRequest.run() (including any internal retries/redirect hops it triggers on the same thread).

The classic engine shares a single CloseableHttpClient across every request the client issues, whether @Remote-originated or an ordinary client.get(url) call. Since neither Apache HttpClient's HttpClientConnectionManager.requestConnection SPI nor its RedirectStrategy SPI receives enough information to distinguish which caller triggered a given connection lease or redirect decision, this thread-local flag is set for the duration of exactly one @Remote invocation (which runs synchronously, blocking the calling thread, per Juneau's classic-engine execution model). While it is set, the client's connection manager leases connections from a dedicated pool whose connections are all opened through the org.apache.juneau.http.remote.RemoteUrlPolicy pin, and its redirect strategy defers 3xx handling to Juneau's revalidating redirect loop — leaving ordinary (non-@Remote) requests on the same client, and their separate pool, completely unaffected.

The guard of the @Remote request itself also travels on the request's HttpContext, so it holds even when the request is executed on another thread; this flag additionally guards any other request made on the calling thread while the call runs.

Since:
10.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Marks the calling thread as executing an SSRF-guard-active @Remote call.
    static void
    Ends one activate(); the calling thread's marker is cleared when the outermost guarded call ends.
    static boolean
    Returns true if the calling thread is currently executing an SSRF-guard-active @Remote call.

    Methods inherited from class java.lang.Object

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

    • activate

      public static void activate()
      Marks the calling thread as executing an SSRF-guard-active @Remote call.

      Callers must invoke deactivate() in a finally block once the call (including any retries) has completed. Calls nest: the thread stays marked until every activate() has been matched by a deactivate(), so a guarded call made while another one is running does not end the outer call's guard.

    • deactivate

      public static void deactivate()
      Ends one activate(); the calling thread's marker is cleared when the outermost guarded call ends.
    • isActive

      public static boolean isActive()
      Returns true if the calling thread is currently executing an SSRF-guard-active @Remote call.
      Returns:
      true if the guard is active on this thread.