Interface MatcherWatchdog

All Known Implementing Classes:
MatcherWatchdog.Default, MatcherWatchdog.Noop

public interface MatcherWatchdog
Provides an interface for protecting code that uses joni's Matcher against long-running operations.

Some implementations of this interface may use threads and timeouts, but the default implementations here are simpler: there's a no-op implementation, and there's an implementation that relies on the Matcher.setTimeout(long) method.

  • Method Details

    • register

      void register(org.joni.Matcher matcher)
      Registers a matcher.
      Parameters:
      matcher - The matcher to register
    • maxExecutionTimeInMillis

      long maxExecutionTimeInMillis()
      Returns:
      The maximum allowed time in milliseconds for a thread to invoke unregister(Matcher) after register(Matcher) has been invoked.
    • unregister

      void unregister(org.joni.Matcher matcher)
      Unregisters a matcher.
      Parameters:
      matcher - The matcher to unregister
    • newInstance

      static MatcherWatchdog newInstance(long maxExecutionTimeMillis)
      Returns an implementation that relies on the Matcher.setTimeout(long) method.
      Parameters:
      maxExecutionTimeMillis - The time in millis that a matcher has to execute an operation.
    • noop

      static MatcherWatchdog noop()
      Returns:
      A noop implementation that does not interrupt threads and is useful for testing and pre-defined grok expressions.