Skip to content

Commit

Permalink
Fix NPE when use SystemRegistry without ConsoleEngine, fixes #515
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Mar 5, 2020
1 parent 7ea73e9 commit e839b9c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -82,7 +81,7 @@ default List<String> commandInfo(String command) {
} catch (Exception e) {

}
return new ArrayList<>();
throw new IllegalArgumentException("default CommandRegistry.commandInfo() method must be overridden in class " + this.getClass().getCanonicalName());
}

/**
Expand Down Expand Up @@ -113,7 +112,7 @@ default Widgets.CmdDesc commandDescription(String command) {
} catch (Exception e) {

}
return null;
throw new IllegalArgumentException("default CommandRegistry.commandDescription() method must be overridden in class " + this.getClass().getCanonicalName());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public enum Pipe {

private static final Class<?>[] BUILTIN_REGISTERIES = { Builtins.class, ConsoleEngineImpl.class };
private CommandRegistry[] commandRegistries;
private Integer consoleId = null;
private Integer consoleId;
private Parser parser;
private ConfigurationPath configPath;
private Map<Command, String> commandName = new HashMap<>();
Expand Down Expand Up @@ -242,7 +242,7 @@ public Completers.SystemCompleter compileCompleters() {
public Completer completer() {
List<Completer> completers = new ArrayList<>();
completers.add(compileCompleters());
if (consoleId > -1) {
if (consoleId != null) {
completers.addAll(consoleEngine().scriptCompleters());
}
return new AggregateCompleter(completers);
Expand Down Expand Up @@ -992,7 +992,7 @@ public Object execute(String line) throws Exception {
CommandData cmd = cmds.get(i);
try {
outputStream.closeAndReset();
if (!consoleEngine().isExecuting()) {
if (consoleId != null && !consoleEngine().isExecuting()) {
trace(cmd);
}
exception = null;
Expand Down Expand Up @@ -1262,7 +1262,7 @@ private Object help(Builtins.CommandInput input) {
printCommands(cmds, max);
}
}
if (consoleId > -1 && isInArgs(opt.args(), "Scripts")) {
if (consoleId != null && isInArgs(opt.args(), "Scripts")) {
printHeader("Scripts");
if (withInfo) {
for (String c : scriptStore.getScripts()) {
Expand Down Expand Up @@ -1313,7 +1313,7 @@ private List<OptDesc> commandOptions(String command) {
private List<String> registryNames() {
List<String> out = new ArrayList<>();
out.add("Builtins");
if (consoleId > -1) {
if (consoleId != null) {
out.add("Scripts");
}
for (CommandRegistry r : commandRegistries) {
Expand Down

0 comments on commit e839b9c

Please sign in to comment.