Commit 465cd1ef authored by Daniel Le Berre's avatar Daniel Le Berre

Shutdown hook no longer added in constructor, to allow unit testing.

For some reason, the code does not compile on my computer, while it
should. Let's see how it goes in CI.
parent d51a52f3
Pipeline #3363 failed with stages
in 2 minutes and 54 seconds
......@@ -117,7 +117,7 @@ public abstract class AbstractLauncher implements Serializable, ILogAble {
this.launcherMode.setIncomplete(isIncomplete);
}
protected AbstractLauncher() {
protected void addHook() {
Runtime.getRuntime().addShutdownHook(this.shutdownHook);
}
......
......@@ -69,6 +69,7 @@ public class BasicLauncher<T extends ISolver> extends AbstractLauncher {
lanceur.usage();
return;
}
lanceur.addHook();
lanceur.run(args);
System.exit(lanceur.getExitCode().value());
}
......
......@@ -239,6 +239,7 @@ public class MUSLauncher extends AbstractLauncher {
lanceur.usage();
return;
}
lanceur.addHook();
lanceur.run(args);
System.exit(lanceur.getExitCode().value());
}
......
......@@ -232,6 +232,7 @@ public class GenericOptLauncher extends AbstractLauncher {
public static void main(String[] args) {
AbstractLauncher lanceur = new GenericOptLauncher();
lanceur.addHook();
lanceur.run(args);
}
......
......@@ -65,8 +65,8 @@ public class LanceurPseudo2005 extends AbstractLauncher implements ILogAble {
}
/**
*
*/
*
*/
private static final long serialVersionUID = 1L;
/**
......@@ -78,6 +78,7 @@ public class LanceurPseudo2005 extends AbstractLauncher implements ILogAble {
*/
public static void main(final String[] args) {
final AbstractLauncher lanceur = new LanceurPseudo2005();
lanceur.addHook();
lanceur.run(args);
System.exit(lanceur.getExitCode().value());
}
......@@ -122,8 +123,8 @@ public class LanceurPseudo2005 extends AbstractLauncher implements ILogAble {
new ObjectiveReducerPBSolverDecorator(theSolver));
}
} else if (System.getProperty("INTERNAL") != null) {
theSolver.setSearchListener(new SearchOptimizerListener(
ILauncherMode.DECISION));
theSolver.setSearchListener(
new SearchOptimizerListener(ILauncherMode.DECISION));
setLauncherMode(ILauncherMode.DECISION);
} else {
if (lower) {
......@@ -141,7 +142,8 @@ public class LanceurPseudo2005 extends AbstractLauncher implements ILogAble {
@Override
public void usage() {
this.out.println("java -jar sat4j-pb.jar [solvername [timeout]] instancename.opb"); //$NON-NLS-1$
this.out.println(
"java -jar sat4j-pb.jar [solvername [timeout]] instancename.opb"); //$NON-NLS-1$
showAvailableSolvers(SolverFactory.instance());
}
......
......@@ -114,6 +114,7 @@ public class Lanceur extends AbstractLauncher implements ILogAble {
public static void main(final String[] args) {
lanceur = new Lanceur();
lanceur.addHook();
lanceur.run(args);
}
......
......@@ -97,6 +97,7 @@ public class Launcher extends AbstractLauncher implements ILogAble {
public static void main(final String[] args) {
launcher = new Launcher();
launcher.addHook();
launcher.run(args);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment