Index: trunk/scripts/SyncEditorLayerIndex.java
===================================================================
--- trunk/scripts/SyncEditorLayerIndex.java	(revision 17331)
+++ trunk/scripts/SyncEditorLayerIndex.java	(revision 17332)
@@ -541,8 +541,8 @@
     // catch reordered arguments and switches to WMS version 1.3.0
     String unifyWMS(String url) {
-        String x[] = url.replaceAll("(?i)VERSION=[0-9.]+", "VERSION=x").replaceAll("(?i)SRS=", "CRS=").split("\\?");
-        String a[] = x[1].split("&");
+        String[] x = url.replaceAll("(?i)VERSION=[0-9.]+", "VERSION=x").replaceAll("(?i)SRS=", "CRS=").split("\\?");
+        String[] a = x[1].split("&");
         Arrays.sort(a);
-        url = x[0]+"?"+String.join("&",a);
+        url = x[0]+"?"+String.join("&", a);
         return url;
     }
@@ -579,5 +579,5 @@
 
                         if (ide.equals(idj) && Objects.equals(getType(j), getType(e))) {
-                            if(getType(j).equals("wms") && unifyWMS(urle).equals(unifyWMS(urlj))) {
+                            if (getType(j).equals("wms") && unifyWMS(urle).equals(unifyWMS(urlj))) {
                                 myprintln("# WMS-URL for id "+idj+" modified: "+getDescription(j));
                             } else {
@@ -591,9 +591,9 @@
                             break;
                         }
-                        Collection<String> old = ((ImageryInfo)j).getOldIds();
-                        if(old != null) {
+                        Collection<String> old = j.getOldIds();
+                        if (old != null) {
                             for (String oidj : old) {
                                 if (ide.equals(oidj) && Objects.equals(getType(j), getType(e))) {
-                                    if(getType(j).equals("wms") && unifyWMS(urle).equals(unifyWMS(urlj))) {
+                                    if (getType(j).equals("wms") && unifyWMS(urle).equals(unifyWMS(urlj))) {
                                         myprintln("# WMS-URL for oldid "+idj+" modified: "+getDescription(j));
                                     } else {
Index: trunk/src/org/openstreetmap/josm/actions/downloadtasks/PostDownloadHandler.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/downloadtasks/PostDownloadHandler.java	(revision 17331)
+++ trunk/src/org/openstreetmap/josm/actions/downloadtasks/PostDownloadHandler.java	(revision 17332)
@@ -124,8 +124,9 @@
         // multiple error object? prepare a HTML list
         //
-        if (!errors.isEmpty() && !GraphicsEnvironment.isHeadless()) {
+        final Collection<String> items = task.getErrorMessages();
+        if (!items.isEmpty() && !GraphicsEnvironment.isHeadless()) {
             SwingUtilities.invokeLater(() -> JOptionPane.showMessageDialog(
                     MainApplication.getMainFrame(),
-                    "<html>"+Utils.joinAsHtmlUnorderedList(task.getErrorMessages())+"</html>",
+                    "<html>"+Utils.joinAsHtmlUnorderedList(items)+"</html>",
                     tr("Errors during download"),
                     JOptionPane.ERROR_MESSAGE));
Index: trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/DataSet.java	(revision 17331)
+++ trunk/src/org/openstreetmap/josm/data/osm/DataSet.java	(revision 17332)
@@ -765,9 +765,8 @@
         OsmPrimitive result = getPrimitiveById(primitiveId);
         if (result == null && primitiveId != null) {
-            Logging.warn(tr(
+            Logging.error(new IllegalStateException(tr(
                     "JOSM expected to find primitive [{0} {1}] in dataset but it is not there. Please report this "
                             + "at {2}. This is not a critical error, it should be safe to continue in your work.",
-                    primitiveId.getType(), Long.toString(primitiveId.getUniqueId()), Config.getUrls().getJOSMWebsite()));
-            Logging.error(new Exception());
+                    primitiveId.getType(), Long.toString(primitiveId.getUniqueId()), Config.getUrls().getJOSMWebsite())));
         }
 
Index: trunk/src/org/openstreetmap/josm/gui/io/DownloadPrimitivesWithReferrersTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/DownloadPrimitivesWithReferrersTask.java	(revision 17331)
+++ trunk/src/org/openstreetmap/josm/gui/io/DownloadPrimitivesWithReferrersTask.java	(revision 17332)
@@ -234,5 +234,7 @@
         }
         List<PrimitiveId> downloaded = new ArrayList<>(ids);
-        downloaded.removeAll(missingPrimitives);
+        if (missingPrimitives != null) {
+            downloaded.removeAll(missingPrimitives);
+        }
         return downloaded;
     }
Index: trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java	(revision 17331)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java	(revision 17332)
@@ -171,5 +171,5 @@
 
         gc.anchor = GridBagConstraints.NORTHWEST;
-        gc.fill = GridBagConstraints.HORIZONTAL;
+        gc.fill = HORIZONTAL;
         gc.weightx = 0.0;
         gc.insets = new Insets(0, 0, 0, 3);
Index: trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadObjectHandler.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadObjectHandler.java	(revision 17331)
+++ trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadObjectHandler.java	(revision 17332)
@@ -6,4 +6,7 @@
 import java.util.LinkedList;
 import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 import java.util.stream.Collectors;
 
@@ -67,5 +70,9 @@
             final DownloadPrimitivesWithReferrersTask task = new DownloadPrimitivesWithReferrersTask(
                     newLayer, ps, referrers, relationMembers, args.get("layer_name"), null);
-            MainApplication.worker.submit(task);
+            try {
+                MainApplication.worker.submit(task).get(OSM_DOWNLOAD_TIMEOUT.get(), TimeUnit.SECONDS);
+            } catch (InterruptedException | ExecutionException | TimeoutException e) {
+                Logging.error(e);
+            }
             MainApplication.worker.submit(() -> {
                 final List<PrimitiveId> downloaded = task.getDownloadedId();
Index: trunk/test/unit/org/openstreetmap/josm/TestUtils.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/TestUtils.java	(revision 17331)
+++ trunk/test/unit/org/openstreetmap/josm/TestUtils.java	(revision 17332)
@@ -480,5 +480,5 @@
 
     /**
-     * Return WireMock server serving files under ticker directory
+     * Return WireMock server serving files under ticket directory
      * @param ticketId Ticket numeric identifier
      * @return WireMock HTTP server on dynamic port
@@ -493,5 +493,5 @@
 
     /**
-     * Return WireMock server serving files under ticker directory
+     * Return WireMock server
      * @return WireMock HTTP server on dynamic port
      */
@@ -499,4 +499,5 @@
             return new WireMockServer(
                     WireMockConfiguration.options()
+                        .withRootDirectory("test/data")
                         .dynamicPort()
                     );
Index: trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/LoadObjectHandlerTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/LoadObjectHandlerTest.java	(revision 17331)
+++ trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/LoadObjectHandlerTest.java	(revision 17332)
@@ -2,12 +2,19 @@
 package org.openstreetmap.josm.io.remotecontrol.handler;
 
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 
+import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
-import org.junit.jupiter.api.Test;
+import org.openstreetmap.josm.TestUtils;
 import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException;
+import org.openstreetmap.josm.spi.preferences.Config;
 import org.openstreetmap.josm.testutils.JOSMTestRules;
+
+import com.github.tomakehurst.wiremock.WireMockServer;
 
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@@ -36,5 +43,6 @@
     @Test
     void testBadRequestNoParam() {
-        assertDoesNotThrow(() -> newHandler(null).handle());
+        Exception e = assertThrows(RequestHandlerBadRequestException.class, () -> newHandler(null).handle());
+        assertEquals("No valid object identifier has been provided", e.getMessage());
     }
 
@@ -62,5 +70,27 @@
     @Test
     void testNominalRequest() {
-        assertDoesNotThrow(() -> newHandler("https://localhost?objects=foo,bar").handle());
+        WireMockServer wiremock = TestUtils.getWireMockServer();
+        wiremock.addStubMapping(get(urlEqualTo("/capabilities")).willReturn(aResponse().withStatusMessage("OK")
+                .withBodyFile("api/capabilities")).build());
+        String w1 = "<way id=\"1\" version=\"1\"><nd ref=\"1\"/><nd ref=\"2\"/></way>";
+        String n1 = "<node id=\"1\" version=\"1\"/>";
+        String n2 = "<node id=\"2\" version=\"1\"/>";
+        wiremock.addStubMapping(get(urlEqualTo("/0.6/ways?ways=1")).willReturn(aResponse().withStatusMessage("OK")
+                .withBody(osm(w1))).build());
+        wiremock.addStubMapping(get(urlEqualTo("/0.6/nodes?nodes=1,2")).willReturn(aResponse().withStatusMessage("OK")
+                .withBody(osm(n1 + n2))).build());
+        wiremock.addStubMapping(get(urlEqualTo("/0.6/way/1/full")).willReturn(aResponse().withStatusMessage("OK")
+                .withBody(osm(n1 + n2 + w1))).build());
+        wiremock.start();
+        Config.getPref().put("osm-server.url", wiremock.baseUrl());
+        try {
+            assertDoesNotThrow(() -> newHandler("https://localhost?objects=n1,w1").handle());
+        } finally {
+            wiremock.stop();
+        }
+    }
+
+    private static String osm(String xml) {
+        return "<osm version=\"0.6\">" + xml + "</osm>";
     }
 }
