JDK-8214295 : Populate handlers while holding streamHandlerLock
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 12
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2018-11-26
  • Updated: 2019-01-28
  • Resolved: 2018-11-27
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 11 JDK 12
11.0.2Fixed 12 b22Fixed
Related Reports
Relates :  
Description
The recent JDK-8213942 fix adjusted the synchronization logic for the handlers Hashtable. A minor enhancement can be made to improve synchronization. 

One thread may release at/around this section while another thread then clears the handlers table in setURLStreamHandlerFactory method :

1418             if (handler2 != null) {
1419                 // The handler from the factory must be given more
1420                 // importance. Discard the default handler that
1421                 // this thread created.
1422                 handler = handler2;
1423             }
1424         }     ===========> HERE
1425 
1426         // Insert this handler into the hashtable
1427         if (handler != null) {
1428             handlers.put(protocol, handler);
1429         }
Comments
The JDK-8213942 testcase also tests for this test scenario
26-11-2018