[ 
https://issues.apache.org/jira/browse/CLI-317?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17754851#comment-17754851
 ] 

Sruteesh Kumar Paramata commented on CLI-317:
---------------------------------------------

Hello Gary

You forgot to add Test annotation to src/test/java/org/apache/commons/cli/ 
[ParserTestCase.java|http://ParserTestCase.java]  
testAmbiguousLongWithoutEqualSingleDash2() 

I have forked the repo, made some changes and the byild is failed

Go through the following repo (CLI-317-NPE branch):

 
[https://github.com/kumarp149/commons-cli/commits/CLI-317-NPE|https://github.com/kumarp149/commons-cli/commits/CLI-317-NPE]
 

Go through the following github action:
 
[https://github.com/kumarp149/commons-cli/actions/runs/5874485562|https://github.com/kumarp149/commons-cli/actions/runs/5874485562]
 


The build is failing with NPE. Kindly check once

> NullPointerException thrown by CommandLineParser.parse()
> --------------------------------------------------------
>
>                 Key: CLI-317
>                 URL: https://issues.apache.org/jira/browse/CLI-317
>             Project: Commons CLI
>          Issue Type: Bug
>          Components: Parser
>    Affects Versions: 1.5.0
>            Reporter: Philippe Bastiani
>            Priority: Critical
>              Labels: exception
>
> # First at all, your *testAmbiguousLongWithoutEqualSingleDash* does not lead 
> to a AmbiguousOptionException
>  # For this same test, if I replace the deprecated OptionBuilder with 
> Option.Builder as follows
> {code:java}
> options.addOption(Option.builder().option("f").longOpt("foo").optionalArg(true).build());
> options.addOption(Option.builder().option("b").longOpt("bar").optionalArg(false).build());
> {code}
> the test leads to a NPE
> {code:java}
> java.lang.NullPointerException
>       at xx.DefaultParser.handleShortAndLongOption(DefaultParser.java:476)
>       at xx.DefaultParser.handleToken(DefaultParser.java:535)
>       at xx.DefaultParser.parse(DefaultParser.java:714)
>       at xx.DefaultParser.parse(DefaultParser.java:677)
>       at xx.DefaultParser.parse(DefaultParser.java:654)
> {code}
> _Note_  : tested with Github code (January 22, 2023)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to