]> WPIA git - gigi.git/commitdiff
FIX: syncing issues for Language initialisation.
authorFelix Dörre <felix@dogcraft.de>
Thu, 11 Sep 2014 20:39:38 +0000 (22:39 +0200)
committerFelix Dörre <felix@dogcraft.de>
Thu, 11 Sep 2014 20:39:38 +0000 (22:39 +0200)
src/org/cacert/gigi/localisation/Language.java

index 5e11f09c58b13049bf156628fda1ac2f7cc6ad73..4c6e39012094281c3736c5e4a73649b93c6bbe80 100644 (file)
@@ -111,15 +111,21 @@ public class Language {
         }
         Language lang = langs.get(locale.toString());
         if (lang == null) {
-            try {
-                lang = new Language(locale);
-                langs.put(locale.toString(), lang);
-            } catch (ParserConfigurationException e) {
-                e.printStackTrace();
-            } catch (IOException e) {
-                e.printStackTrace();
-            } catch (SAXException e) {
-                e.printStackTrace();
+            synchronized (Language.class) {
+                lang = langs.get(locale.toString());
+                if (lang != null) {
+                    return lang;
+                }
+                try {
+                    lang = new Language(locale);
+                    langs.put(locale.toString(), lang);
+                } catch (ParserConfigurationException e) {
+                    e.printStackTrace();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                } catch (SAXException e) {
+                    e.printStackTrace();
+                }
             }
         }
         return lang;