Changeset 15789 in josm for trunk/src/org


Ignore:
Timestamp:
2020-01-27T22:40:13+01:00 (5 years ago)
Author:
Don-vip
Message:

see #18613 - fix regressions

Location:
trunk/src/org/openstreetmap/josm/actions/downloadtasks
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmChangeTask.java

    r15784 r15789  
    1010import java.util.Map;
    1111import java.util.Map.Entry;
     12import java.util.Optional;
    1213import java.util.concurrent.Future;
    1314import java.util.concurrent.RejectedExecutionException;
     
    6566    @Override
    6667    public Future<?> loadUrl(DownloadParams settings, final String url, ProgressMonitor progressMonitor) {
    67         OsmChangeUrlPattern urlPattern = Arrays.stream(OsmChangeUrlPattern.values()).filter(p -> p.matches(url)).findFirst()
    68                 .orElseThrow(() -> new IllegalArgumentException("URL does not match any OSM URL pattern: " + url));
     68        Optional<OsmChangeUrlPattern> urlPattern = Arrays.stream(OsmChangeUrlPattern.values()).filter(p -> p.matches(url)).findFirst();
    6969        String newUrl = url;
    7070        final Matcher matcher = OsmChangeUrlPattern.OSM_WEBSITE.matcher(url);
     
    7575                Compression.byExtension(newUrl));
    7676        // Extract .osc filename from URL to set the new layer name
    77         extractOsmFilename(settings, urlPattern.pattern(), newUrl);
     77        extractOsmFilename(settings, urlPattern.orElse(OsmChangeUrlPattern.EXTERNAL_OSC_FILE).pattern(), newUrl);
    7878        return MainApplication.worker.submit(downloadTask);
    7979    }
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    r15784 r15789  
    159159    public Future<?> loadUrl(DownloadParams settings, String url, ProgressMonitor progressMonitor) {
    160160        String newUrl = modifyUrlBeforeLoad(url);
    161         OsmUrlPattern urlPattern = Arrays.stream(OsmUrlPattern.values()).filter(p -> p.matches(newUrl)).findFirst()
    162                 .orElseThrow(() -> new IllegalArgumentException("URL does not match any OSM URL pattern: " + newUrl));
     161        Optional<OsmUrlPattern> urlPattern = Arrays.stream(OsmUrlPattern.values()).filter(p -> p.matches(newUrl)).findFirst();
    163162        downloadTask = new DownloadTask(settings, getOsmServerReader(newUrl), progressMonitor, true, Compression.byExtension(newUrl));
    164163        currentBounds = null;
    165164        // Extract .osm filename from URL to set the new layer name
    166         extractOsmFilename(settings, urlPattern.pattern(), newUrl);
     165        extractOsmFilename(settings, urlPattern.orElse(OsmUrlPattern.EXTERNAL_OSM_FILE).pattern(), newUrl);
    167166        return MainApplication.worker.submit(downloadTask);
    168167    }
     
    190189        if (newLayerName == null || newLayerName.isEmpty()) {
    191190            Matcher matcher = Pattern.compile(pattern).matcher(url);
    192             newLayerName = matcher.matches() ? matcher.group(1) : null;
     191            newLayerName = matcher.matches() && matcher.groupCount() > 0 ? matcher.group(1) : null;
    193192        }
    194193    }
Note: See TracChangeset for help on using the changeset viewer.