Class JstackTimeoutExtension

  • All Implemented Interfaces:
    org.apache.maven.surefire.extensions.ForkedProcessTimeoutExtension

    public class JstackTimeoutExtension
    extends java.lang.Object
    implements org.apache.maven.surefire.extensions.ForkedProcessTimeoutExtension
    Built-in ForkedProcessTimeoutExtension that captures a jstack thread dump of the forked test JVM just before it is killed because of forkedProcessTimeoutInSeconds.

    The output is written to <reportsDirectory>/surefire-timeout-jstack-<forkNumber>-<pid>.txt.

    Activation: this extension is registered via META-INF/services but is disabled by default. To enable it set the system property surefire.timeout.jstack.enabled=true on the Maven process (for example with MAVEN_OPTS or -Dsurefire.timeout.jstack.enabled=true). The jstack binary is resolved from ${java.home}/bin/jstack, the parent JDK bin (Java 8 layout), $JAVA_HOME/bin/jstack, and finally from PATH.

    Since:
    3.6.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ENABLED_KEY
      Extension-context key that enables this extension from the POM via the forkedProcessTimeoutExtensionContext Mojo parameter.
      static java.lang.String ENABLED_PROPERTY
      System property that enables this extension.
      static java.lang.String OUTPUT_LOCATION_KEY
      Extension context key that overrides the directory where the surefire-timeout-jstack-*.txt files are written.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void onForkExited​(org.apache.maven.surefire.extensions.ForkedProcessTimeoutContext context, org.apache.maven.surefire.api.suite.RunResult runResult)  
      void onTimeoutDetected​(org.apache.maven.surefire.extensions.ForkedProcessTimeoutContext context)  
      • Methods inherited from class java.lang.Object

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

      • ENABLED_PROPERTY

        public static final java.lang.String ENABLED_PROPERTY
        System property that enables this extension.
        See Also:
        Constant Field Values
      • ENABLED_KEY

        public static final java.lang.String ENABLED_KEY
        Extension-context key that enables this extension from the POM via the forkedProcessTimeoutExtensionContext Mojo parameter. Set to true to enable. When either this key or ENABLED_PROPERTY is set to true, the extension runs.
        See Also:
        Constant Field Values
      • OUTPUT_LOCATION_KEY

        public static final java.lang.String OUTPUT_LOCATION_KEY
        Extension context key that overrides the directory where the surefire-timeout-jstack-*.txt files are written. When the key is missing or blank, the Surefire reports directory is used.
        See Also:
        Constant Field Values
    • Constructor Detail

      • JstackTimeoutExtension

        public JstackTimeoutExtension()
    • Method Detail

      • onTimeoutDetected

        public void onTimeoutDetected​(org.apache.maven.surefire.extensions.ForkedProcessTimeoutContext context)
        Specified by:
        onTimeoutDetected in interface org.apache.maven.surefire.extensions.ForkedProcessTimeoutExtension
      • onForkExited

        public void onForkExited​(org.apache.maven.surefire.extensions.ForkedProcessTimeoutContext context,
                                 org.apache.maven.surefire.api.suite.RunResult runResult)
        Specified by:
        onForkExited in interface org.apache.maven.surefire.extensions.ForkedProcessTimeoutExtension