Skip to content

Opaque stacktrace for "%" in Option description #615

@petermr

Description

@petermr

If a naked percent character occurs in an option, a large and impenetrable stack trace is thrown.

@Option(names = {"--excludebase"}, 
    		arity="1..*",
    		description = "exclude child files of cTree (only works with --ctree). "
    				+ "Currently must be explicit or with trailing % for truncated glob."
    		)
	public String[] excludeBase;

gives

java.util.MissingFormatArgumentException: Format specifier '% f'
	at java.util.Formatter.format(Formatter.java:2519)
	at java.util.Formatter.format(Formatter.java:2455)
	at java.lang.String.format(String.java:2940)
	at picocli.CommandLine$Model$ArgSpec.renderedDescription(CommandLine.java:5120)
	at picocli.CommandLine$Help$DefaultOptionRenderer.renderDescriptionLines(CommandLine.java:9239)
	at picocli.CommandLine$Help$DefaultOptionRenderer.render(CommandLine.java:9212)
	at picocli.CommandLine$Help.calcLongOptionColumnWidth(CommandLine.java:8832)
	at picocli.CommandLine$Help.parameterList(CommandLine.java:8867)
	at picocli.CommandLine$Model$UsageMessageSpec$8.render(CommandLine.java:4515)
	at picocli.CommandLine.usage(CommandLine.java:1647)
	at picocli.CommandLine.usage(CommandLine.java:1621)
	at picocli.CommandLine.usage(CommandLine.java:1591)
	at picocli.CommandLine$DefaultExceptionHandler.internalHandleParseException(CommandLine.java:1060)
	at picocli.CommandLine$DefaultExceptionHandler.handleParseException(CommandLine.java:1055)
	at picocli.CommandLine.parseWithHandlers(CommandLine.java:1528)
	at picocli.CommandLine.call(CommandLine.java:1786)
	at picocli.CommandLine.call(CommandLine.java:1710)
	at org.contentmine.ami.tools.AbstractAMITool.runCommands(AbstractAMITool.java:206)
	at org.contentmine.ami.tools.AbstractAMITool.runCommands(AbstractAMITool.java:194)
	at org.contentmine.ami.tools.AMIImageTest.testBinarizeTrees(AMIImageTest.java:171)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

This is not easy to interpret. What are the rules for including "%" escaping and can the error be trapped more meaningfully?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions