JDK-8331494 : BasicDirectoryModel/LoaderThreadCount.java fails in CI
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 23
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: linux,os_x,windows
  • CPU: x86_64,aarch64
  • Submitted: 2024-05-01
  • Updated: 2024-11-06
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
tbdUnresolved
Related Reports
Cloners :  
Relates :  
Sub Tasks
JDK-8331495 :  
Description
After JDK-8331142 was integrated, the test/jdk/javax/swing/plaf/basic/BasicDirectoryModel/LoaderThreadCount.java test has failed twice in CI with different errors:

macos-aarch64:
Exception in Test Runner: class java.lang.RuntimeException: Invalid results: no loader threads detected
java.lang.RuntimeException: Invalid results: no loader threads detected
        at LoaderThreadCount.runTest(LoaderThreadCount.java:148)
        at LoaderThreadCount.wrapper(LoaderThreadCount.java:107)
        at java.base/java.lang.Thread.run(Thread.java:1575)

That is the background thread is not found in any of the 20 snapshots of live threads taken.

macos-x64:
Number of snapshots: 17
Number of snapshots where number of loader threads:
  = 1: 15
  = 2: 1
  > 2: 1
Exception in Test Runner: class java.lang.RuntimeException: Detected 1 snapshots with several loading threads
java.lang.RuntimeException: Detected 1 snapshots with several loading threads
        at LoaderThreadCount.runTest(LoaderThreadCount.java:167)
        at LoaderThreadCount.wrapper(LoaderThreadCount.java:107)
        at java.base/java.lang.Thread.run(Thread.java:1575)

The first condition is unexpected.

The second condition is unexpected either, yet its nature is different. It may still be possible that a thread is interrupted but isn't terminated yet. Similar to the 2 threads in the snapshots.
Comments
I cloned this bug to handle the failure on Windows JDK-8331999. As of this moment, there are 10 failures of the test on Windows in CI. I re-linked them to JDK-8331999. I'll leave this bug to track changes for Linux and macOS.
09-05-2024

All the failures found on Windows look the same: Number of snapshots: 20 Number of snapshots where number of loader threads: = 1: 19 = 2: 0 > 2: 1 Exception in Test Runner: class java.lang.RuntimeException: Detected 1 snapshots with several loading threads java.lang.RuntimeException: Detected 1 snapshots with several loading threads at LoaderThreadCount.runTest(LoaderThreadCount.java:168) at LoaderThreadCount.wrapper(LoaderThreadCount.java:108) at java.base/java.lang.Thread.run(Thread.java:1575) A kind of tolerance may be needed. For example, fail the test if the number of snapshots with more than 2 loading threads is above 2 or 3. Without the fix, the number of such snapshots is much higher, usually at 20 out of 20, the lowest I've seen over the recent days is 16. A fraction of the number of (valid) snapshots could be used, for instance SNAPSHOTS / 2 or loaderCount.size() / 2, both usually give 10 on Windows.
08-05-2024

There has now been a failure on WIndows too === Number of snapshots: 20 Number of snapshots where number of loader threads: = 1: 19 = 2: 0 > 2: 1 Duration: 11,328 System.err Exception in Test Runner: class java.lang.RuntimeException: Detected 1 snapshots with several loading threads java.lang.RuntimeException: Detected 1 snapshots with several loading threads at LoaderThreadCount.runTest(LoaderThreadCount.java:167) at LoaderThreadCount.wrapper(LoaderThreadCount.java:107) at java.base/java.lang.Thread.run(Thread.java:1575) JavaTest Message: Test threw exception: java.lang.RuntimeException: Detected 1 snapshots with several loading threads JavaTest Message: shutting down test STATUS:Failed.`main' threw exception: java.lang.RuntimeException: Detected 1 snapshots with several loading threads
01-05-2024

Before submitting the test for code review, I ran it multiple times on the platforms and I never saw such failures. The test needs to be more stable. One of the workarounds for this is to limit the test to Windows only. The File Loading Threads are very slow on Windows because listing files depends on the COM thread; each file loading thread is serialized via the COM thread. This is the reason why the test is very stable on Windows. On Linux and macOS, the file loading threads are independent; they may complete quickly or they may linger for a while.
01-05-2024