Index: core/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java	(revision 14344)
+++ core/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java	(date 1539809084000)
@@ -11,6 +11,7 @@
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.Future;
 import java.util.regex.Matcher;
@@ -250,27 +251,57 @@
             return getModifiableDataLayers().findFirst().orElse(null);
         }
 
-        protected OsmDataLayer createNewLayer(String layerName) {
-            if (layerName == null || layerName.isEmpty()) {
-                layerName = settings.getLayerName();
-            }
-            if (layerName == null || layerName.isEmpty()) {
-                layerName = OsmDataLayer.createNewName();
+        /**
+         * Creates a name for a new layer by utilizing the settings ({@link DownloadParams#getLayerName()}) or
+         * {@link OsmDataLayer#createNewName()} if the former option is {@code null}.
+         *
+         * @return a name for a new layer
+         */
+        protected String generateLayerName() {
+            return Optional.ofNullable(settings.getLayerName())
+                .orElse(OsmDataLayer.createNewName());
+        }
+
+        /**
+         * Can be overridden (e.g. by plugins) if a subclass of {@link OsmDataLayer} is needed.
+         * If you want to change how the name is determined, consider overriding
+         * {@link #generateLayerName()} instead.
+         *
+         * @param dataset the dataset on which the layer is based, must be non-null
+         * @param layerName the name of the new layer, must be non-blank
+         * @return a new instance of {@link OsmDataLayer} constructed with the given arguments
+         */
+        protected OsmDataLayer createNewLayer(final DataSet dataset, final String layerName) {
+            if (Utils.isStripEmpty(layerName)) {
+                throw new IllegalArgumentException("Blank layer name!");
             }
-            if (settings.getDownloadPolicy() != null) {
-                dataSet.setDownloadPolicy(settings.getDownloadPolicy());
-            }
-            if (settings.getUploadPolicy() != null) {
-                dataSet.setUploadPolicy(settings.getUploadPolicy());
-            }
+            return new OsmDataLayer(
+                Objects.requireNonNull(dataset, "dataset parameter"),
+                Objects.requireNonNull(layerName, "layerName parameter"),
+                null
+            );
+        }
+
+        //TODO: Make final as soon as this method is no longer overridden by plugins, change param type to Optional<String>
+        protected OsmDataLayer createNewLayer(final String layerName) {
+            Optional.ofNullable(settings.getDownloadPolicy())
+                .ifPresent(dataSet::setDownloadPolicy);
+            Optional.ofNullable(settings.getUploadPolicy())
+                .ifPresent(dataSet::setUploadPolicy);
             if (dataSet.isLocked() && !settings.isLocked()) {
                 dataSet.unlock();
             } else if (!dataSet.isLocked() && settings.isLocked()) {
                 dataSet.lock();
             }
-            return new OsmDataLayer(dataSet, layerName, null);
+            return createNewLayer(
+                dataSet,
+                Optional.ofNullable(layerName)
+                    .filter(it -> !Utils.isStripEmpty(it))
+                    .orElseGet(this::generateLayerName)
+            );
         }
 
+        //TODO: Remove this method as soon as it is no longer overridden by plugins
         protected OsmDataLayer createNewLayer() {
             return createNewLayer(null);
         }
