Class JsonSchemaCancellation
The rest-utils blanket request timeout (request.timeout.ms with request.timeout.interrupt.enable=true) interrupts the Jetty worker thread once a request exceeds its wall-clock budget. That timeout is the universal backstop: it abandons the request with an HTTP 504 regardless of where it is stuck. This helper is the optimization layered on top — it lets the code paths we own notice the interrupt promptly, abort, and return the pooled thread to service instead of burning CPU to completion.
IMPORTANT: this is cooperative. It only fires in code that calls
throwIfInterrupted().
The third-party schema loaders (org.everit.json.schema and
com.github.erosb.jsonsKema) do their own (potentially exponential) $ref resolution and do
not poll the interrupt flag, so a parse already in flight inside those libraries is reclaimed
only by the request timeout, not by this check. Calling throwIfInterrupted() at our
entry points (before a parse is kicked off) is the closest cooperative guard we can place around
that path.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidAborts the current operation if the worker thread has been interrupted (e.g.
-
Method Details
-
throwIfInterrupted
public static void throwIfInterrupted()Aborts the current operation if the worker thread has been interrupted (e.g. by the request timeout).Thread.interrupted()also clears the interrupt flag so the pooled thread returns clean to the executor.- Throws:
CancellationException- if the current thread's interrupt flag was set
-