Index: /trunk/src/org/openstreetmap/josm/tools/Territories.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/Territories.java	(revision 16551)
+++ /trunk/src/org/openstreetmap/josm/tools/Territories.java	(revision 16552)
@@ -128,5 +128,5 @@
      * Initializes territories using the internal data only.
      */
-    public static void initializeInternalData() {
+    public static synchronized void initializeInternalData() {
         iso3166Cache = new HashMap<>();
         taginfoCache = new TreeMap<>();
@@ -167,5 +167,6 @@
             throw new JosmRuntimeException(ex);
         } finally {
-            MultipolygonCache.getInstance().clear(dataSet);
+            if (dataSet != null)
+                MultipolygonCache.getInstance().clear(dataSet);
             if (!Logging.isDebugEnabled()) {
                 // unset dataSet to save memory, see #18907
