SUGGESTED FIX
Of course, my previous comment is completely wrong,
because initialization of "bugLevel" has to be delayed until after
System property infrastructure has been set up.
I agree with the suggested fix.... except that....
I think we can get away without a "volatile" on this variable.
This is skating on thin ice, but appears to be safe here because:
- redundant initialization of "bugLevel" is harmless
- String is one of the very few classes that is race-safe. That is,
if multiple threads access a String, even in the presence of a data race,
they are guaranteed to see the same value.
|
SUGGESTED FIX
------- Charset.java -------
*** /tmp/sccs.FhaqDt Thu Feb 22 17:51:08 2007
--- Charset.java Thu Feb 22 17:40:52 2007
***************
*** 243,249 ****
/* -- Static methods -- */
! private static String bugLevel = null;
static boolean atBugLevel(String bl) { // package-private
if (bugLevel == null) {
--- 243,249 ----
/* -- Static methods -- */
! private static volatile String bugLevel = null;
static boolean atBugLevel(String bl) { // package-private
if (bugLevel == null) {
***************
*** 251,261 ****
return false;
java.security.PrivilegedAction pa =
new GetPropertyAction("sun.nio.cs.bugLevel");
! bugLevel = (String)AccessController.doPrivileged(pa);
! if (bugLevel == null)
! bugLevel = "";
}
! return (bugLevel != null) && bugLevel.equals(bl);
}
/**
--- 251,260 ----
return false;
java.security.PrivilegedAction pa =
new GetPropertyAction("sun.nio.cs.bugLevel");
! String value = (String)AccessController.doPrivileged(pa);
! bugLevel = (value != null) ? value : "";
}
! return bugLevel.equals(bl);
}
/**
|