JDK-6915621 : (rb) ResourceBundle.getBundle() deadlock when called inside a synchronized thread
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 6u17
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2010-01-11
  • Updated: 2014-05-06
  • Resolved: 2010-10-13
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 7
7 b114Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
Calling ResourceBundle.getBundle() from within a synchronized object causes a dead lock.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Step 1 - Run main in TestDevice class shown below.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Entering run...
GyMdkHmsSEDFwWahKzZ
Tue Jan 05 15:38:26 CST 2010
Finished reading data...
setting running=false
closing....

ACTUAL -
Entering run...


ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error message received, just deadlocks.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package test;
  
  import java.util.ResourceBundle;
  import java.util.Locale;
  import java.util.Date;
  
  public class TestDevice extends Thread
  {
  	  boolean running = true;
  	
      public synchronized boolean isRunning()
      {
          return running;
      }
  
      public void run()
      {
          running = true;
          try
          {
          	System.out.println("Entering run...");
            ResourceBundle myResources = ResourceBundle.getBundle("sun.text.resources.DateFormatZoneData", Locale.US);
            System.out.println(myResources.getString("localPatternChars"));
            System.out.println(new Date());
            System.out.println("Finished reading data...");
          }
          finally
          {
            System.out.println("setting running=false");
            running = false;
          }
      }
  
      public static void main(String[] args) {

        TestDevice device = null;
        try
        {
            device = new TestDevice();
            synchronized (device)
            {
              device.start();
              while (device.isRunning())
              {
              }
            }
        } finally
        {
            System.out.println("closing....");
            device = null;
        }
      }
  }
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Works fine in Java 1.4 and 1.5.

Release Regression From : 5.0u18
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Comments
EVALUATION After all the underConstruction mechanism is the source of dead lock problems. We decided to eliminate underConstruction in JDK7 as well.
13-01-2010

EVALUATION A Thread shouldn't be used for locking inside ResourceBundle after all. The symptom is not reproducible with the 6609468 fix (6u19). A fix needs in JDK 7.
12-01-2010