Skip to content

Commit fe807de

Browse files
committed
RunArgument: fix NPE when no script args are given
The intent was that you could write e.g.: myApp --run myScript Instead of requiring that an empty args list be passed like: myApp --run myScript '' But in practice, the former was generating a NullPointerException.
1 parent 20b4873 commit fe807de

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/main/java/org/scijava/run/console/RunArgument.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,17 @@ public void handle(final LinkedList<String> args) {
7676
final String code = args.removeFirst();
7777
final String arg = getParam(args);
7878

79-
final Items items = parser.parse(arg);
8079
try {
8180
if (arg == null) runService.run(code);
82-
else if (items.isMap()) runService.run(code, items.asMap());
83-
else if (items.isList()) runService.run(code, items.toArray());
8481
else {
85-
throw new IllegalArgumentException("Arguments are inconsistent. " +
86-
"Please pass either a list of key/value pairs, " +
87-
"or a list of values.");
82+
final Items items = parser.parse(arg);
83+
if (items.isMap()) runService.run(code, items.asMap());
84+
else if (items.isList()) runService.run(code, items.toArray());
85+
else {
86+
throw new IllegalArgumentException("Arguments are inconsistent. " +
87+
"Please pass either a list of key/value pairs, " +
88+
"or a list of values.");
89+
}
8890
}
8991
}
9092
catch (final InvocationTargetException exc) {

0 commit comments

Comments
 (0)