Ticket #15182: 15182.sys_exit.patch

File 15182.sys_exit.patch, 5.3 KB (added by taylor.smock, 4 years ago)

Replace Sys.exit with Lifecycle.exitJosm, also change some instances of System.err.println to Logging.error.

  • src/org/openstreetmap/josm/data/projection/ProjectionCLI.java

    diff --git a/src/org/openstreetmap/josm/data/projection/ProjectionCLI.java b/src/org/openstreetmap/josm/data/projection/ProjectionCLI.java
    index cdb7807081..1dcbb51be9 100644
    a b import org.openstreetmap.josm.cli.CLIModule;  
    1919import org.openstreetmap.josm.data.coor.EastNorth;
    2020import org.openstreetmap.josm.data.coor.LatLon;
    2121import org.openstreetmap.josm.data.coor.conversion.LatLonParser;
     22import org.openstreetmap.josm.spi.lifecycle.Lifecycle;
     23import org.openstreetmap.josm.tools.Logging;
    2224import org.openstreetmap.josm.tools.OptionParser;
    2325
    2426/**
    public class ProjectionCLI implements CLIModule {  
    7476        try {
    7577            run(fromStr, toStr, otherPositional);
    7678        } catch (ProjectionConfigurationException | IllegalArgumentException | IOException ex) {
    77             System.err.println(tr("Error: {0}", ex.getMessage()));
    78             System.exit(1);
     79            Logging.error(ex);
     80            Lifecycle.exitJosm(true, 1);
    7981        }
    80         System.exit(0);
     82        Lifecycle.exitJosm(true, 0);
    8183    }
    8284
    8385    /**
    public class ProjectionCLI implements CLIModule {  
    8587     */
    8688    private static void showHelp() {
    8789        System.out.println(getHelp());
    88         System.exit(0);
     90        Lifecycle.exitJosm(true, 0);
    8991    }
    9092
    9193    private static String getHelp() {
  • src/org/openstreetmap/josm/data/validation/ValidatorCLI.java

    diff --git a/src/org/openstreetmap/josm/data/validation/ValidatorCLI.java b/src/org/openstreetmap/josm/data/validation/ValidatorCLI.java
    index 595d7d70c2..cd4164c37f 100644
    a b import org.openstreetmap.josm.tools.Utils;  
    6868 * @since 18365
    6969 */
    7070public class ValidatorCLI implements CLIModule {
    71         /**
    72         * The unique instance.
    73         */
     71    /**
     72    * The unique instance.
     73    */
    7474    public static final ValidatorCLI INSTANCE = new ValidatorCLI();
    7575
    7676    /** The input file(s) */
    public class ValidatorCLI implements CLIModule {  
    384384        switch (option) {
    385385        case HELP:
    386386            showHelp();
    387             System.exit(0);
     387            Lifecycle.exitJosm(true, 0);
    388388            break;
    389389        case DEBUG:
    390390            this.logLevel = Logging.LEVEL_DEBUG;
  • src/org/openstreetmap/josm/gui/MainApplication.java

    diff --git a/src/org/openstreetmap/josm/gui/MainApplication.java b/src/org/openstreetmap/josm/gui/MainApplication.java
    index 8aa31512fa..c2848b500f 100644
    a b public class MainApplication {  
    276276            try {
    277277                args = new ProgramArguments(argArray);
    278278            } catch (IllegalArgumentException e) {
    279                 System.err.println(e.getMessage());
    280                 System.exit(1);
     279                Logging.error(e);
     280                Lifecycle.exitJosm(true, 1);
    281281            }
    282282            mainJOSM(args);
    283283        }
    public class MainApplication {  
    12401240                    Logging.log(Logging.LEVEL_ERROR,
    12411241                            tr("''{0}'' is not a valid value for argument ''{1}''. Possible values are {2}, possibly delimited by commas.",
    12421242                            s.toUpperCase(Locale.ENGLISH), Option.OFFLINE.getName(), Arrays.toString(OnlineResource.values())), e);
    1243                     System.exit(1);
     1243                    Lifecycle.exitJosm(true, 1);
    12441244                    return;
    12451245                }
    12461246            }
  • src/org/openstreetmap/josm/gui/mappaint/RenderingCLI.java

    diff --git a/src/org/openstreetmap/josm/gui/mappaint/RenderingCLI.java b/src/org/openstreetmap/josm/gui/mappaint/RenderingCLI.java
    index a92dd1780d..4ec4db901b 100644
    a b import org.openstreetmap.josm.gui.mappaint.RenderingHelper.StyleData;  
    3838import org.openstreetmap.josm.io.Compression;
    3939import org.openstreetmap.josm.io.IllegalDataException;
    4040import org.openstreetmap.josm.io.OsmReader;
     41import org.openstreetmap.josm.spi.lifecycle.Lifecycle;
    4142import org.openstreetmap.josm.spi.preferences.Config;
    4243import org.openstreetmap.josm.spi.preferences.MemoryPreferences;
    4344import org.openstreetmap.josm.tools.Http1Client;
    public class RenderingCLI implements CLIModule {  
    176177                e.printStackTrace();
    177178            }
    178179            System.err.println(tr("Error - file not found: ''{0}''", e.getMessage()));
    179             System.exit(1);
     180            Lifecycle.exitJosm(true, 1);
    180181        } catch (IllegalArgumentException | IllegalDataException | IOException e) {
    181182            if (Logging.isDebugEnabled()) {
    182183                e.printStackTrace();
    183184            }
    184185            if (e.getMessage() != null) {
    185                 System.err.println(tr("Error: {0}", e.getMessage()));
     186                Logging.error(e);
    186187            }
    187             System.exit(1);
     188            Lifecycle.exitJosm(true, 1);
    188189        }
    189         System.exit(0);
     190        Lifecycle.exitJosm(true, 0);
    190191    }
    191192
    192193    /**
    public class RenderingCLI implements CLIModule {  
    227228        switch (o) {
    228229        case HELP:
    229230            showHelp();
    230             System.exit(0);
     231            Lifecycle.exitJosm(true, 0);
    231232            break;
    232233        case DEBUG:
    233234            argDebug = true;