Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE in DefaultParamLabelRenderer.renderParameterLabel #1043

Closed
remkop opened this issue May 14, 2020 · 0 comments
Closed

NPE in DefaultParamLabelRenderer.renderParameterLabel #1043

remkop opened this issue May 14, 2020 · 0 comments
Milestone

Comments

@remkop
Copy link
Owner

remkop commented May 14, 2020

When running Groovy CliBuilder tests with picocli 4.3.0, the following error occurs:

  • CliBuilderTest.testAnnotationsInterfaceToStringWithName
  • CliBuilderTest.testMandatoryParametersDoNotConsumeOtherOptions
  • CliBuilderTest.testMultipleOccurrencesSeparateSeparate3
  • CliBuilderTest.testLongOptionsRequireDoubleHyphenByDefault
  • CliBuilderTest.testAcceptLongOptionsWithSingleHyphen_usage
  • CliBuilderTest.testGroovyDocAntExample
  • CliBuilderTest.testAnnotationsInterfaceToStringWithUsage
java.lang.NullPointerException
	at picocli.CommandLine$Help$DefaultParamLabelRenderer.renderParameterLabel(CommandLine.java:15041)
	at picocli.CommandLine$Help.createDetailedSynopsisOptionsText(CommandLine.java:14146)
	at picocli.CommandLine$Help.detailedSynopsis(CommandLine.java:14072)
	at picocli.CommandLine$Help.synopsis(CommandLine.java:14026)
	at picocli.CommandLine$Model$UsageMessageSpec$5.render(CommandLine.java:7209)
	at picocli.CommandLine.usage(CommandLine.java:2565)
	at picocli.CommandLine.usage(CommandLine.java:2543)
	at picocli.CommandLine.usage(CommandLine.java:2499)
	at picocli.CommandLine$usage.call(Unknown Source)
	at groovy.cli.picocli.CliBuilder.printUsage(CliBuilder.groovy:644)

The error occurs on this line:

String split = argSpec.splitRegexSynopsisLabel().isEmpty() ? argSpec.splitRegex() : argSpec.splitRegexSynopsisLabel();

which suggests that argSpec.splitRegexSynopsisLabel() returns null.

Looking at the ArgSpec constructor, this seems to be caused by a copy-and-paste bug:

// actual
splitRegex = builder.splitRegex == null ? "" : builder.splitRegex;
splitRegexSynopsisLabel = builder.splitRegex == null ? "" : builder.splitRegexSynopsisLabel;

Should be:

splitRegex = builder.splitRegex == null ? "" : builder.splitRegex;
splitRegexSynopsisLabel = builder.splitRegexSynopsisLabel== null ? "" : builder.splitRegexSynopsisLabel;
@remkop remkop added this to the 4.3.1 milestone May 14, 2020
remkop added a commit that referenced this issue May 14, 2020
…erer.renderParameterLabel` for programmatically built models that have a non-`null` `split` regex and do not have a `splitSynopsisLabel`.
@remkop remkop closed this as completed May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant