JDK-8156169 : Some sound tests rarely hangs because of incorrect synchronization
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.sound
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2016-05-05
  • Updated: 2020-10-12
  • Resolved: 2016-05-18
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.
JDK 8 JDK 9 Other
8u270Fixed 9 b124Fixed openjdk8u272Fixed
Description
I just found one of the reason why some of our tests hangs. Example of the test:
closed/javax/sound/sampled/Clip/bug5070081.java 

The problem is that the tests uses this pattern:
clip.start();
while(clip.isRunning());

The status running or not is updated on a different thread, but our clip implementations lack of synchronization of getters and the hotspot inline such methods to while(true).
Comments
8u Fix Request: I would like to backport this patch to 8u, as Oracle 8u271 parity. The original patch does not apply cleanly. Other than file path changes, there are a few copyright line conflicts. One code conflict is in src/share/classes/javax/sound/midi/Sequence.java's getTracks() method. It appears 8u and 9u have different implementation 8u review thread: https://mail.openjdk.java.net/pipermail/jdk8u-dev/2020-June/012037.html (reviewed)
24-06-2020