apache / apache/maven-surefire

[SUREFIRE-1879] M5 swallows exception output from shutdown hooks

Open
#2,976 5 comments 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
461
Forks
588
Avg merge
1d 8h
Merged PRs (30d)
19

Description

**[Falko Modler](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=famod)** opened **[SUREFIRE-1879](https://issues.apache.org/jira/browse/SUREFIRE-1879?redirect=false)** and commented

With 3.0.0-M5, an exception from a shutdown hook is not printed to the console.

This works as expected with 3.0.0-M4.

To reproduce, run the project from the attached zipfile:

```
mvn test
```

```
[INFO] Running org.apache.maven.surefire.HookOutputTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.029 s - in org.apache.maven.surefire.HookOutputTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
```

Sometimes you at least see:

```
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.033 s - in org.apache.maven.surefire.HookOutputTest
Exception in thread "Thread-1" [INFO]
[INFO] Results:
```

So it looks like a timing issue?

In comparison:

```
mvn test -Dsurefire.version=3.0.0-M4
```

```
[INFO] Running org.apache.maven.surefire.HookOutputTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.028 s - in org.apache.maven.surefire.HookOutputTest
Exception in thread "Thread-3" java.lang.IllegalStateException: test
at org.apache.maven.surefire.HookOutputTest.lambda$testHookOutput$0(HookOutputTest.java:10)
at org.apache.maven.surefire.HookOutputTest$$Lambda$314/000000000000000000.run(Unknown Source)
at java.base/java.lang.Thread.run(Thread.java:836)
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
```

PS: I originally ran into this here: https://github.com/quarkusio/quarkus/pull/14311#pullrequestreview-569179938

---

**Affects:** 3.0.0-M5

**Attachments:**
- [surefire-bug-hook-output.zip](https://issues.apache.org/jira/secure/attachment/13019034/surefire-bug-hook-output.zip) (_3.80 kB_)

**Issue Links:**
- [SUREFIRE-1877](https://issues.apache.org/jira/browse/SUREFIRE-1877) Can't print from a shutdown hook
(_**"is duplicated by"**_)

Contributor guide

Open the contributing guide

Research direction

Start with the attached surefire-bug-hook-output.zip and run mvn test to reproduce the missing shutdown-hook exception output. Compare the result with mvn test -Dsurefire.version=3.0.0-M4, using HookOutputTest and its testHookOutput method as the entry point; done means the exception and stack trace are printed reliably.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.