git://source.jalview.org
/
jalview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
519889b
)
JAL-629 All applications System.exits going through Jalview.exit
author
Ben Soares
<b.soares@dundee.ac.uk>
Fri, 17 Mar 2023 21:15:30 +0000
(21:15 +0000)
committer
Ben Soares
<b.soares@dundee.ac.uk>
Fri, 17 Mar 2023 21:15:30 +0000
(21:15 +0000)
src/jalview/bin/ArgParser.java
patch
|
blob
|
history
src/jalview/bin/Commands.java
patch
|
blob
|
history
src/jalview/bin/Jalview.java
patch
|
blob
|
history
src/jalview/bin/Launcher.java
patch
|
blob
|
history
src/jalview/gui/Desktop.java
patch
|
blob
|
history
src/jalview/io/NewickFile.java
patch
|
blob
|
history
src/jalview/util/AWTConsole.java
patch
|
blob
|
history
diff --git
a/src/jalview/bin/ArgParser.java
b/src/jalview/bin/ArgParser.java
index
14785ea
..
fca2320
100644
(file)
--- a/
src/jalview/bin/ArgParser.java
+++ b/
src/jalview/bin/ArgParser.java
@@
-1199,20
+1199,20
@@
public class ArgParser
{
if (!argFile.exists())
{
{
if (!argFile.exists())
{
- System.err.println(DOUBLEDASH
+ String message = DOUBLEDASH
+ Arg.ARGFILE.name().toLowerCase(Locale.ROOT) + "=\""
+ Arg.ARGFILE.name().toLowerCase(Locale.ROOT) + "=\""
- + argFile.getPath() + "\": File does not exist.");
- System.exit(2);
+ + argFile.getPath() + "\": File does not exist.";
+ Jalview.exit(message, 2);
}
try
{
argsList.addAll(Files.readAllLines(Paths.get(argFile.getPath())));
} catch (IOException e)
{
}
try
{
argsList.addAll(Files.readAllLines(Paths.get(argFile.getPath())));
} catch (IOException e)
{
- System.err.println(DOUBLEDASH
+ String message = DOUBLEDASH
+ Arg.ARGFILE.name().toLowerCase(Locale.ROOT) + "=\""
+ Arg.ARGFILE.name().toLowerCase(Locale.ROOT) + "=\""
- + argFile.getPath() + "\": File could not be read.");
- System.exit(3);
+ + argFile.getPath() + "\": File could not be read.";
+ Jalview.exit(message, 3);
}
}
return new ArgParser(argsList);
}
}
return new ArgParser(argsList);
diff --git
a/src/jalview/bin/Commands.java
b/src/jalview/bin/Commands.java
index
26ce8c3
..
f71ebf3
100644
(file)
--- a/
src/jalview/bin/Commands.java
+++ b/
src/jalview/bin/Commands.java
@@
-374,8
+374,7
@@
public class Commands
{
if (headless)
{
{
if (headless)
{
- Console.error("Could not open any files in headless mode");
- System.exit(1);
+ Jalview.exit("Could not open any files in headless mode", 1);
}
else
{
}
else
{
diff --git
a/src/jalview/bin/Jalview.java
b/src/jalview/bin/Jalview.java
index
a728bc8
..
fbbb16c
100755
(executable)
--- a/
src/jalview/bin/Jalview.java
+++ b/
src/jalview/bin/Jalview.java
@@
-365,9
+365,9
@@
public class Jalview
} catch (NoClassDefFoundError error)
{
error.printStackTrace();
} catch (NoClassDefFoundError error)
{
error.printStackTrace();
- System.out.println("\nEssential logging libraries not found."
- + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview");
- System.exit(0);
+ String message = "\nEssential logging libraries not found."
+ + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview";
+ Jalview.exit(message, 0);
}
// register SIGTERM listener
}
// register SIGTERM listener
@@
-427,7
+427,7
@@
public class Jalview
|| argparser.getBool(Arg.HELP))
{
showUsage();
|| argparser.getBool(Arg.HELP))
{
showUsage();
- System.exit(0);
+ Jalview.exit(null, 0);
}
if (bootstrapArgs.contains(Arg.HEADLESS))
}
if (bootstrapArgs.contains(Arg.HEADLESS))
@@
-501,9
+501,9
@@
public class Jalview
NoClassDefFoundError error)
{
error.printStackTrace();
NoClassDefFoundError error)
{
error.printStackTrace();
- System.out.println("\nEssential logging libraries not found."
- + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview");
- System.exit(0);
+ String message = "\nEssential logging libraries not found."
+ + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview";
+ Jalview.exit(message, 0);
}
desktop = null;
}
desktop = null;
@@
-647,18
+647,19
@@
public class Jalview
boolean commandsSuccess = cmds.argsWereParsed();
if (commandsSuccess)
{
boolean commandsSuccess = cmds.argsWereParsed();
if (commandsSuccess)
{
- Console.info("Successfully completed commands");
if (headlessArg)
{
if (headlessArg)
{
- System.out.println("#### EXITING");
- System.exit(0);
+ Jalview.exit("Successfully completed commands in headless mode", 0);
}
}
+ Console.info("Successfully completed commands");
}
else
{
}
else
{
- Console.warn("Error when running commands");
if (headlessArg)
if (headlessArg)
- System.exit(1);
+ {
+ Jalview.exit("Error when running Commands in headless mode", 1);
+ }
+ Console.warn("Error when running commands");
}
// Check if JVM and compile version might cause problems and log if it
}
// Check if JVM and compile version might cause problems and log if it
@@
-706,8
+707,7
@@
public class Jalview
if (file == null && desktop == null)
{
if (file == null && desktop == null)
{
- System.out.println("No files to open!");
- System.exit(1);
+ Jalview.exit("No files to open!", 1);
}
long progress = -1;
}
long progress = -1;
@@
-734,11
+734,12
@@
public class Jalview
{
if (!(new File(file)).exists())
{
{
if (!(new File(file)).exists())
{
- System.out.println("Can't find " + file);
if (headless)
{
if (headless)
{
- System.exit(1);
+ Jalview.exit(
+ "Can't find file '" + file + "' in headless mode", 1);
}
}
+ Console.warn("Can't find file'" + file + "'");
}
}
}
}
}
}
@@
-1578,8
+1579,7
@@
public class Jalview
public void quit()
{
// System.exit will run the shutdownHook first
public void quit()
{
// System.exit will run the shutdownHook first
- System.out.println("Quitting now. Bye!");
- System.exit(0);
+ Jalview.exit("Quitting now. Bye!", 0);
}
public static AlignFrame getCurrentAlignFrame()
}
public static AlignFrame getCurrentAlignFrame()
@@
-1596,4
+1596,17
@@
public class Jalview
{
return cmds;
}
{
return cmds;
}
+
+ public static void exit(String message, int exitcode)
+ {
+ System.err.println("####### EXITING HERE!");
+ Console.debug("Using Jalview.exit");
+ if (message != null)
+ if (exitcode == 0)
+ Console.info(message);
+ else
+ Console.error(message);
+ if (exitcode > -1)
+ System.exit(exitcode);
+ }
}
}
diff --git
a/src/jalview/bin/Launcher.java
b/src/jalview/bin/Launcher.java
index
9e1fb51
..
cab2c00
100644
(file)
--- a/
src/jalview/bin/Launcher.java
+++ b/
src/jalview/bin/Launcher.java
@@
-254,7
+254,6
@@
public class Launcher
{
e.printStackTrace();
}
{
e.printStackTrace();
}
- // System.exit(0);
}
}
}
}
diff --git
a/src/jalview/gui/Desktop.java
b/src/jalview/gui/Desktop.java
index
ba7665b
..
981a060
100644
(file)
--- a/
src/jalview/gui/Desktop.java
+++ b/
src/jalview/gui/Desktop.java
@@
-1436,8
+1436,7
@@
public class Desktop extends jalview.jbgui.GDesktop
// this will run the shutdownHook but QuitHandler.getQuitResponse() should
// not run a second time if gotQuitResponse flag has been set (i.e. user
// confirmed quit of some kind).
// this will run the shutdownHook but QuitHandler.getQuitResponse() should
// not run a second time if gotQuitResponse flag has been set (i.e. user
// confirmed quit of some kind).
- System.out.println("Desktop exiting.");
- System.exit(0);
+ Jalview.exit("Desktop exiting.", 0);
}
private void storeLastKnownDimensions(String string, Rectangle jc)
}
private void storeLastKnownDimensions(String string, Rectangle jc)
diff --git
a/src/jalview/io/NewickFile.java
b/src/jalview/io/NewickFile.java
index
027390a
..
98978d0
100755
(executable)
--- a/
src/jalview/io/NewickFile.java
+++ b/
src/jalview/io/NewickFile.java
@@
-26,19
+26,19
@@
// TODO: Extended SequenceNodeI to hold parsed NHX strings
package jalview.io;
// TODO: Extended SequenceNodeI to hold parsed NHX strings
package jalview.io;
-import java.util.Locale;
-
-import jalview.datamodel.SequenceNode;
-import jalview.util.MessageManager;
-
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
+import java.util.Locale;
import java.util.StringTokenizer;
import com.stevesoft.pat.Regex;
import java.util.StringTokenizer;
import com.stevesoft.pat.Regex;
+import jalview.bin.Jalview;
+import jalview.datamodel.SequenceNode;
+import jalview.util.MessageManager;
+
/**
* Parse a new hanpshire style tree Caveats: NHX files are NOT supported and the
* tree distances and topology are unreliable when they are parsed. TODO: on
/**
* Parse a new hanpshire style tree Caveats: NHX files are NOT supported and the
* tree distances and topology are unreliable when they are parsed. TODO: on
@@
-487,7
+487,8
@@
public class NewickFile extends FileParse
{
try
{
{
try
{
- distance = (Double.valueOf(ndist.stringMatched(1))).floatValue();
+ distance = (Double.valueOf(ndist.stringMatched(1)))
+ .floatValue();
HasDistances = true;
nodehasdistance = true;
} catch (Exception e)
HasDistances = true;
nodehasdistance = true;
} catch (Exception e)
@@
-944,9
+945,8
@@
public class NewickFile extends FileParse
{
if (args == null || args.length != 1)
{
{
if (args == null || args.length != 1)
{
- System.err.println(
- "Takes one argument - file name of a newick tree file.");
- System.exit(0);
+ Jalview.exit(
+ "Takes one argument - file name of a newick tree file.", 0);
}
File fn = new File(args[0]);
}
File fn = new File(args[0]);
diff --git
a/src/jalview/util/AWTConsole.java
b/src/jalview/util/AWTConsole.java
index
ab049a3
..
cf44dcb
100644
(file)
--- a/
src/jalview/util/AWTConsole.java
+++ b/
src/jalview/util/AWTConsole.java
@@
-48,6
+48,8
@@
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.io.PrintStream;
import java.io.PipedOutputStream;
import java.io.PrintStream;
+import jalview.bin.Jalview;
+
public class AWTConsole extends WindowAdapter
implements WindowListener, ActionListener, Runnable
{
public class AWTConsole extends WindowAdapter
implements WindowListener, ActionListener, Runnable
{
@@
-174,8
+176,7
@@
public class AWTConsole extends WindowAdapter
} catch (Exception e)
{
}
} catch (Exception e)
{
}
- System.out.println("Window closing. Bye!");
- System.exit(0);
+ Jalview.exit("Window closing. Bye!", 0);
}
@Override
}
@Override