Close the fixture in oak run console
@@ -44,9 +44,8 @@ public class Console {
Options opts = new Options();
OptionSet options = opts.parseAndConfigure(parser, args);
-
- NodeStoreFixture fixture = NodeStoreFixtureProvider.create(opts);
-
+ int code = 0;
+ try (NodeStoreFixture fixture = NodeStoreFixtureProvider.create(opts)) {
List<String> nonOptions = opts.getCommonOpts().getNonOptions();
List<String> scriptArgs = nonOptions.size() > 1 ?
nonOptions.subList(1, nonOptions.size()) : Collections.emptyList();
@@ -63,7 +62,6 @@ public class Console {
GroovyConsole console =
new GroovyConsole(ConsoleSession.create(fixture.getStore(), fixture.getWhiteboard()), new IO(), fixture);
- int code = 0;
if (!scriptArgs.isEmpty()) {
code = console.execute(scriptArgs);
}
@@ -71,6 +69,7 @@ public class Console {
if (scriptArgs.isEmpty() || options.has(shell)) {
code = console.run();
}
+ }
System.exit(code);
}
