提交 ed9c2ab8 编写于 作者: S sherman

6527572: (cs) Charset.forName can throw NullPointerException when testing bug level

Summary: fixed the race condition
Reviewed-by: alanb
上级 36490a1a
...@@ -275,18 +275,17 @@ public abstract class Charset ...@@ -275,18 +275,17 @@ public abstract class Charset
/* -- Static methods -- */ /* -- Static methods -- */
private static String bugLevel = null; private static volatile String bugLevel = null;
static boolean atBugLevel(String bl) { // package-private static boolean atBugLevel(String bl) { // package-private
if (bugLevel == null) { String level = bugLevel;
if (level == null) {
if (!sun.misc.VM.isBooted()) if (!sun.misc.VM.isBooted())
return false; return false;
bugLevel = AccessController.doPrivileged( bugLevel = level = AccessController.doPrivileged(
new GetPropertyAction("sun.nio.cs.bugLevel")); new GetPropertyAction("sun.nio.cs.bugLevel", ""));
if (bugLevel == null)
bugLevel = "";
} }
return (bugLevel != null) && bugLevel.equals(bl); return level.equals(bl);
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册