Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-1029

Report suppressed exceptions

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 2.15, 2.16
    • None
    • Maven Surefire Plugin
    • None

    Description

      Surefire only reports the exception from a try-with-resources body, not any suppressed exceptions from close methods. I see this behavior from the attached AutoCloseableMain.java:

      Exception in thread "main" java.io.IOException: from body
              at AutoCloseableMain.main(AutoCloseableMain.java:9)
              Suppressed: java.io.IOException: from close
                      at ThrowIOExceptionOnClose.close(AutoCloseableMain.java:17)
                      at AutoCloseableMain.main(AutoCloseableMain.java:10)
      

      I see a different behavior from the attached AutoCloseableTest.java:

      java.io.IOException: from body
              at com.maginatics.AutoCloseableTest.testAutoCloseable(AutoCloseableTest.java:14)
      

      Surefire could call Throwable.getSuppressed via reflection to maintain compatibility with earlier versions of Java. Refer to Guava Closer which does something similar.

      Attachments

        1. AutoCloseableMain.java
          0.5 kB
          Andrew Gaul
        2. AutoCloseableTest.java
          0.5 kB
          Andrew Gaul

        Activity

          People

            tibordigana Tibor Digana
            gaul Andrew Gaul
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: