JDK-8346222 : SwingNodePlatformExitCrashTest fails with JUnit 5.11.3
  • Type: Bug
  • Component: javafx
  • Sub-Component: swing
  • Affected Version: jfx24
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-12-13
  • Updated: 2024-12-16
  • Resolved: 2024-12-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
jfx24 masterFixed
Related Reports
Relates :  
Relates :  
Description
The update of JUnit to 5.11.3 in JDK-8345937 uncovered a latent test bug in SwingNodePlatformExitCrashTest. That test now fails with JUnit 5.11.3.


The following test consistently fails on macOS and Linux (I haven't tried it on Windows) with JUnit 5.11.3 in our CI and on my local macOS system:

$ gradle -PTEST_ONLY=true -PFULL_TEST=true -PUSE_ROBOT=true :systemTests:test --tests SwingNodePlatformExitCrashTest
...
SwingNodePlatformExitCrashTest > executionError FAILED
    org.opentest4j.AssertionFailedError: Exceeded timeout limit of 10000 msec
        at app//test.util.Util.runAndWait(Util.java:168)
        at app//test.util.Util.runAndWait(Util.java:139)
        at app//test.util.Util.shutdown(Util.java:316)
        at app//test.robot.javafx.embed.swing.SwingNodeBase.teardownOnce(SwingNodeBase.java:81)
        at java.base@23/java.lang.reflect.Method.invoke(Method.java:580)
        at java.base@23/java.util.ArrayList.forEach(ArrayList.java:1597)
        at java.base@23/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1117)
        at java.base@23/java.util.ArrayList.forEach(ArrayList.java:1597)

The abstract SwingNodeBase base class calls Util::shutdown from a static tearDownOnce method, annotated with @AfterAll. The SwingNodePlatformExitCrashTest shuts down the FX toolkit as part of the test so must not call shutdown a second time. The current test logic attempts to "override" the static method in the base class with an @AfterAll annotation on a static method of the same name in the subclass. This accidentally works in JUnit 5.8 by hiding the method in the parent class, but no longer does in JUnit 5.11.

The right fix is for the subclass to set a flag such that the superclass will skip the call to Util::shutdown.
Comments
Changeset: 56175f40 Branch: master Author: Kevin Rushforth <kcr@openjdk.org> Date: 2024-12-16 13:03:23 +0000 URL: https://git.openjdk.org/jfx/commit/56175f40037a6a03f65a99d26b74c7b110d29b70
16-12-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jfx/pull/1664 Date: 2024-12-13 19:46:54 +0000
13-12-2024