Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6915621

(rb) ResourceBundle.getBundle() deadlock when called inside a synchronized thread

XMLWordPrintable

    • 6
    • b114
    • x86
    • windows_xp

      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.

            naoto Naoto Sato
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: