Changeset 13402 in josm for trunk/src


Ignore:
Timestamp:
2018-02-10T15:07:48+01:00 (6 years ago)
Author:
Don-vip
Message:

fix #15901 - --load-preferences crashes on simple filename

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r13396 r13402  
    2222import java.net.ProxySelector;
    2323import java.net.URL;
     24import java.nio.file.Paths;
    2425import java.security.AllPermission;
    2526import java.security.CodeSource;
     
    169170import org.openstreetmap.josm.tools.Territories;
    170171import org.openstreetmap.josm.tools.Utils;
    171 import org.openstreetmap.josm.tools.bugreport.BugReport;
    172172import org.openstreetmap.josm.tools.bugreport.BugReportExceptionHandler;
    173173import org.openstreetmap.josm.tools.bugreport.BugReportQueue;
     
    954954            XMLCommandProcessor config = new XMLCommandProcessor(Main.pref);
    955955            for (String i : args.get(Option.LOAD_PREFERENCES)) {
    956                 Logging.info("Reading preferences from " + i);
    957                 try (InputStream is = Utils.openStream(new URL(i))) {
    958                     config.openAndReadXML(is);
     956                try {
     957                    URL url = i.contains("://") ? new URL(i) : Paths.get(i).toUri().toURL();
     958                    Logging.info("Reading preferences from " + url);
     959                    try (InputStream is = Utils.openStream(url)) {
     960                        config.openAndReadXML(is);
     961                    }
    959962                } catch (IOException ex) {
    960                     throw BugReport.intercept(ex).put("file", i);
     963                    Logging.error(ex);
     964                    return;
    961965                }
    962966            }
Note: See TracChangeset for help on using the changeset viewer.