JDK-8142982 : Race Condition can cause CacheEntry.getJarSigningData() to return null.
  • Type: Bug
  • Component: deploy
  • Affected Version: 9
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2015-11-13
  • Updated: 2016-07-19
  • Resolved: 2015-11-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.
JDK 8 JDK 9
8u101Fixed 9 b96Fixed
Description
CacheEntry.getJarSigningData() checks the SoftReference signingDataRef to get the info for a given cache entry.  If the return is null it then computes it from the JarFile directly, and places the result in the signingDataRef, then just a few lines later it returns signingDataRef.get().
Unfortunately, this means that for a few lines of code there is no hard ref to the computed data, and it may be garbage collected (or explicitly cleared.)
Instead CacheEntry.getJarSigningData() should compute the JarSigningData and keep it in a local variable until it can return it (also storing it in the softReference).
This problem is seen intermittently in the CacheJarFileTest unit test.
although there are other failures in this test, the 2 intermittent Errors caused by a null pointer exception in CachedJarFileTest.runEntryGetCertificates() and CachedJarFileTest.runEntryGetCodeSigniers() are caused by this.
The tests loop thu the hundreds of entries in a signed jar, and clear the soft references to them both synchronously and asynchronously, and will get an NPE if the call to JarFileEntry.getCodeSigners() returns null.
I can see this happen about 50% of the time running this test in netbeans, but never with the fix.

The problem is a regression caused by the fix to JDK-8140400
Comments
crucible: https://java.se.oracle.com/code/cru/CR-JDK9CLIENT-1535
13-11-2015