Interface PreInterruptCallback

  • All Superinterfaces:
    Extension

    @API(status=MAINTAINED,
         since="5.13.3")
    public interface PreInterruptCallback
    extends Extension
    PreInterruptCallback defines the API for Extensions that wish to be called prior to invocations of Thread.interrupt() by the Timeout extension.

    JUnit registers a default implementation that dumps the stacks of all threads to System.out if the "junit.jupiter.execution.timeout.threaddump.enabled" configuration parameter is set to true.

    Since:
    5.12
    See Also:
    Timeout
    • Field Detail

      • THREAD_DUMP_ENABLED_PROPERTY_NAME

        @API(status=MAINTAINED,
             since="5.13.3")
        static final java.lang.String THREAD_DUMP_ENABLED_PROPERTY_NAME
        Property name used to enable dumping the stack of all threads to System.out when a timeout has occurred.

        This behavior is disabled by default.

        Since:
        5.12
        See Also:
        Constant Field Values
    • Method Detail

      • beforeThreadInterrupt

        @API(status=MAINTAINED,
             since="5.13.3")
        void beforeThreadInterrupt​(PreInterruptContext preInterruptContext,
                                   ExtensionContext extensionContext)
                            throws java.lang.Exception
        Callback that is invoked before a Thread is interrupted with Thread.interrupt().

        Note: There is no guarantee on which Thread this callback will be executed.

        Parameters:
        preInterruptContext - the context with the target Thread, which will get interrupted.
        extensionContext - the extension context for the callback; never null
        Throws:
        java.lang.Exception
        Since:
        5.12
        See Also:
        PreInterruptContext