changeset 12649:b8faab65bb62 JEP-252-branch

parentLocalesMap init fix
author naoto
date Wed, 24 Jun 2015 09:08:54 -0700
parents 122d91948048
children 137988c40d6a
files src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java	Tue Jun 23 13:17:12 2015 -0700
+++ b/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java	Wed Jun 24 09:08:54 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
 import java.text.spi.CollatorProvider;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Locale;
@@ -40,8 +41,6 @@
 import java.util.ServiceLoader;
 import java.util.Set;
 import java.util.StringTokenizer;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
 import sun.util.locale.provider.JRELocaleProviderAdapter;
 import sun.util.locale.provider.LocaleProviderAdapter;
 import sun.util.locale.provider.LocaleDataMetaInfo;
@@ -59,7 +58,7 @@
     private final LocaleDataMetaInfo nonBaseMetaInfo;
 
     // parent locales map
-    private static ConcurrentMap<Locale, Locale> parentLocalesMap = null;
+    private static volatile Map<Locale, Locale> parentLocalesMap = null;
 
     public CLDRLocaleProviderAdapter() {
         try {
@@ -148,14 +147,15 @@
 
     private List<Locale> applyParentLocales(String baseName, List<Locale> candidates) {
         if (Objects.isNull(parentLocalesMap)) {
-            parentLocalesMap = new ConcurrentHashMap<>();
+            Map<Locale, Locale> map = new HashMap<>();
             Map<String, String> parentLocales = baseMetaInfo.parentLocales();
             parentLocales.keySet().forEach(parent -> {
                 Arrays.asList(parentLocales.get(parent).split(" ")).stream().forEach(child -> {
-                    parentLocalesMap.put(Locale.forLanguageTag(child),
+                    map.put(Locale.forLanguageTag(child),
                         "root".equals(parent) ? Locale.ROOT : Locale.forLanguageTag(parent));
                 });
             });
+            parentLocalesMap = Collections.unmodifiableMap(map);
         }
 
         // check irregular parents