Class ThreadStateValidator


  • public class ThreadStateValidator
    extends java.lang.Object
    Interface to support thread state validation. The basic idea is that one or more validators can be registered with an implementation of the TSV. The validators are executed whenever a thread is returned to the threadpool, For example, a validator may check for unreleased locks or uncleared threadlocals. This is intended as a last-ditch backstop for leaking resource problems.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.List<java.lang.Runnable> validators  
      private static Exceptions wrapper  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void checkValidators()
      Execute all of the validators.
      static void registerValidator​(java.lang.Runnable validator)
      Register a thread validator (represented as a Runnable).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • wrapper

        private static final Exceptions wrapper
      • validators

        private static final java.util.List<java.lang.Runnable> validators
    • Constructor Detail

      • ThreadStateValidator

        private ThreadStateValidator()
    • Method Detail

      • registerValidator

        public static void registerValidator​(java.lang.Runnable validator)
        Register a thread validator (represented as a Runnable). A validator may check for locks that should not be held, check for threadlocals that should be cleared, or take any other action to check for resources that should not be held once the thread is no longer needed, as signaled by the thread being returned to the threadpool.

        A validator typically may take the following actions:

        1. Check whether or not a resource has been released.
        2. Log any detected problems.
        3. Reclaim the resource.
        A validator should NOT throw an exception, as all exceptions thrown from a validator will be ignored.
        Parameters:
        validator -
      • checkValidators

        public static void checkValidators()
        Execute all of the validators. Should only be called from the threadpool implementation.