Class ThreadLeakChecker


  • public class ThreadLeakChecker
    extends Object
    Check for leaked threads in the test suite.

    Every second record new threads and the tests that might have started them. After the last test, log the threads that are still running and the source tests.

    Strategies for debugging test suite thread leaks:

    • Use -Dinfinispan.test.parallel.threads=3 (or even less) to narrow down source tests
    • Set a conditional breakpoint in Thread.start with the name of the leaked thread
    • If the thread has the pattern of a particular component, set a conditional breakpoint in that component
    Since:
    10.0
    Author:
    Dan Berindei
    • Constructor Detail

      • ThreadLeakChecker

        public ThreadLeakChecker()
    • Method Detail

      • testStarted

        public static void testStarted​(String testName)
        A test class has started, and we should consider it as a potential owner for new threads.
      • saveInitialThreads

        public static void saveInitialThreads()
        Save the system threads in order to ignore them
      • testFinished

        public static void testFinished​(String testName)
        A test class has finished, and we should not consider it a potential owner for new threads any more.
      • checkForLeaks

        public static void checkForLeaks​(String lastTestName)
        Check for leaked threads. Assumes that no tests are running.
      • ignoreThreadsMatching

        public static void ignoreThreadsMatching​(Predicate<Thread> filter)
        Ignore threads matching a predicate.
      • ignoreThread

        public static void ignoreThread​(Thread thread)
        Ignore a running thread.
      • ignoreThreadsContaining

        public static void ignoreThreadsContaining​(String threadNameRegex)
        Ignore threads containing a regex.