JDK-7117936 : java.util.Locale getDefault() initialization is broken
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2011-12-04
  • Updated: 2012-03-20
  • Resolved: 2011-12-07
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
Java source code, both 1.6 and 1.7

A DESCRIPTION OF THE PROBLEM :
java.util.Locale.getDefault() has following flaw: As nothing in the source code seems to impose any multithread visibility constraints (happen-before relationships) it is possible for field defaultLocale to have non-null value before the default-locale-instance is fully initialized. Same problem exists in java.lang.Math.random().




REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
Both can be fixed by making variable in question volatile.

Comments
EVALUATION Looks like a duplicate of 4808233.
07-12-2011