You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Hook before timeout exception is started by calling interrupt()Β #2938
The problem: When having sporadic timeout exceptions, it is hard to tell from the stacktrace where the code was hanging.
A debugger might not be available (sporadic, on build system)
Also the stackdump of other threads might be very helpful, because the timeout might be caused by other threads activity or dead lock.
An own extension seems to be not reasonable, as the timeout control also from maven, is part of the infrastructure.
Deliverables
Either have a hook, that gets called before the thread.interrupt() is called in org.junit.jupiter.engine.extension.TimeoutInvocation.InterruptTask.run().
Or have a way to activate collecting a stackdump of all threads (just before calling interrupt() as above) and put it into the TimeoutException.
Or have collected stackdumps of all threads as information always in the TimeoutException
Can you please add more information how your pom file looks like, which Maven versions, JDK version etc. you are using... Also which surefire-plugin versions etc. ?
To make the problem perhaps even better understandable...
Given a test running code that triggers parallel workers and somehow waits for completion. If then the task (in test-thread) gets interrupted due to timeout, it might catch the InterruptedException and force the parallel workers to be closed before rethrowing. So at the time, the timeout exception can be caught from a live cycle method, it might be already too late to see the status of the parallel workers right before the interruption.
Hence I think it would be very helpful to have a hook that runs just before the thread.interrupt() call.
Having the all-thread-dump from JUnit directly would be helpful, but I can also image that a screenshot or other actions can be helpful.
Team decision: Add a PreInterruptCallbackExtension API and a default implementation that prints a thread dump of the current JVM to System.out if a new Jupiter-specific configuration parameter is set to true.
This issue was resolved and the conversation been locked due to inactivity.
The JUnit team generally speaking doesn't look at resolved issues. If you do have a similar request or problem, please create a new issue. You can include a reference to this issue to provide additional context.
Activity
khmarbaise commentedon Jul 30, 2022
Can you please add more information how your pom file looks like, which Maven versions, JDK version etc. you are using... Also which surefire-plugin versions etc. ?
frankbenoit commentedon Jul 30, 2022
maven 3.8.6,
surefire 2.22.2,
JDK 17
To make the problem perhaps even better understandable...
Given a test running code that triggers parallel workers and somehow waits for completion. If then the task (in test-thread) gets interrupted due to timeout, it might catch the InterruptedException and force the parallel workers to be closed before rethrowing. So at the time, the timeout exception can be caught from a live cycle method, it might be already too late to see the status of the parallel workers right before the interruption.
Hence I think it would be very helpful to have a hook that runs just before the
thread.interrupt()call.Having the all-thread-dump from JUnit directly would be helpful, but I can also image that a screenshot or other actions can be helpful.
The location of the interrupt call is meanwhile here: https://github.com/junit-team/junit5/blob/main/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/SameThreadTimeoutInvocation.java#L79
axelfontaine commentedon Mar 5, 2023
+1 here
This is not Maven-specific.
Something like
@Timeout(value = 600, threadDump = true)would cover IDEs, Maven, Gradle and whatnot in one go.Here is a proposed solution: https://stackoverflow.com/a/73156213/350428
Integrating this directly into JUnit itself would make it accessible to a much wider audience.
marcphilipp commentedon Jun 30, 2023
Team decision: Add a
PreInterruptCallbackExtensionAPI and a default implementation that prints a thread dump of the current JVM toSystem.outif a new Jupiter-specific configuration parameter is set totrue.marcphilipp commentedon Jun 30, 2023
@frankbenoit Would you be interested in submitting a PR for this?
frankbenoit commentedon Jul 1, 2023
@marcphilipp no, sorry, not at the moment
9 remaining items
PreInterruptCallback extension
PreInterruptCallback extension
PreInterruptCallback extension
PreInterruptCallback extension
PreInterruptCallback extension
PreInterruptCallback extension
Introduce PreInterruptCallback extension point (junit-team#3431)
github-actions commentedon May 4, 2026
This issue was resolved and the conversation been locked due to inactivity.
The JUnit team generally speaking doesn't look at resolved issues. If you do have a similar request or problem, please create a new issue. You can include a reference to this issue to provide additional context.