Package org.mockserver.matchers
Class MatchingTimeoutExecutor
- java.lang.Object
-
- org.mockserver.matchers.MatchingTimeoutExecutor
-
public final class MatchingTimeoutExecutor extends Object
Shared daemon-thread executor used by request matchers (regex, XPath) to bound the runtime of pathological user-supplied expressions. Wrapping each match in a Future-with-timeout protects MockServer from ReDoS / XPath DoS attacks where a single malicious expectation or input would otherwise pin a Netty worker thread.The pool is cached (not single-thread) so concurrent matches do not serialize, and daemon-flagged so it never blocks JVM shutdown.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceMatchingTimeoutExecutor.OnTimeout
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> TcallWithTimeout(Callable<T> task, long timeoutMillis, T onTimeout, MatchingTimeoutExecutor.OnTimeout onTimeoutCallback)Run a matching task with a millisecond timeout.
-
-
-
Method Detail
-
callWithTimeout
public static <T> T callWithTimeout(Callable<T> task, long timeoutMillis, T onTimeout, MatchingTimeoutExecutor.OnTimeout onTimeoutCallback) throws Exception
Run a matching task with a millisecond timeout. A non-positive timeout disables the timeout and runs the task on the calling thread (preserving pre-timeout behaviour for users who opt out).- Returns:
- the task's result, or
onTimeoutwhen the timeout fires - Throws:
Exception- any checked exception thrown by the task (other than TimeoutException)
-
-