You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider the following option: @Option(name = "-i", aliases = {"--import"}, usage = "Usage") public String[] doImport;
If the respective CLI program is called without specifying the -i switch and the usage is printed, the following exception will occur:
Exception in thread "main" java.lang.NullPointerException
at java.lang.reflect.Array.getLength(Native Method)
at org.kohsuke.args4j.spi.ArrayFieldSetter.getValueList(ArrayFieldSetter.java:113)
at org.kohsuke.args4j.spi.OptionHandler.printDefaultValue(OptionHandler.java:139)
at org.kohsuke.args4j.CmdLineParser.createDefaultValuePart(CmdLineParser.java:358)
at org.kohsuke.args4j.CmdLineParser.printOption(CmdLineParser.java:335)
at org.kohsuke.args4j.CmdLineParser.printUsage(CmdLineParser.java:303)
at org.kohsuke.args4j.CmdLineParser.printUsage(CmdLineParser.java:273)
at org.kohsuke.args4j.CmdLineParser.printUsage(CmdLineParser.java:263)
Workaround:
If the String[] is changed to List<String>, the NPE won't appear.
The text was updated successfully, but these errors were encountered:
We also met the same issue here, a possible workaround is to initialize the array field with empty {}, but is really a pitty. The solution seems very clear that in ArrayFieldSetter line 113 we need to take account the possibility that the local variable array is null. I would happily provide a PULL request for this, but would anyone being able to review and accept it?
Consider the following option:
@Option(name = "-i", aliases = {"--import"}, usage = "Usage") public String[] doImport;
If the respective CLI program is called without specifying the
-i
switch and the usage is printed, the following exception will occur:Workaround:
If the
String[]
is changed toList<String>
, the NPE won't appear.The text was updated successfully, but these errors were encountered: