Skip to content

[javadoc] Option.getValues() returns null if there are no values - #456

Open
sergiparpal wants to merge 1 commit into
apache:masterfrom
sergiparpal:javadoc-option-getvalues
Open

sergiparpal wants to merge 1 commit into
apache:masterfrom
sergiparpal:javadoc-option-getvalues

Conversation

@sergiparpal

Copy link
Copy Markdown

The Javadoc of Option.getValues() says:

Gets the values of this Option as a String array or an empty array if there are no values.

When there are no values, the method returns null:

public String[] getValues() {
    return isValuesEmpty() ? null : values.toArray(EMPTY_STRING_ARRAY);
}

The Javadoc said null until #334 (CLI-340, released in 1.10.0). That pull request changed it together with the Javadoc of getValuesList(), which does return an empty list, but getValues() itself was not changed. It returns null, as getValue() does, and DefaultParserTest.testPropertiesDoNotChangeRegisteredOption() asserts that null. It has returned null since 1.0, so returning an empty array instead would change behavior that callers may rely on.

This PR puts null back in the Javadoc of getValues(). It changes Javadoc only.

  • Read the contribution guidelines for this project.
  • Read the ASF Generative Tooling Guidance if you use Artificial Intelligence (AI).
  • I used AI to create any part of, or all of, this pull request. Which AI tool was used to create this pull request, and to what extent did it contribute? Claude Code. A run with Claude Sonnet 5 flagged the mismatch; Claude Opus 5.5 checked it against the code, the tests and the project history, and wrote the change and this description.
  • Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best practice. Not applicable: the change is to Javadoc only.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process.

The Javadoc of Option.getValues() says it returns an empty array if there
are no values, but it returns null. The Javadoc said null until the pull
request for CLI-340 (apache#334, in 1.10.0), which changed it together with
getValuesList()'s; that one does return an empty list. getValues() was
not changed and still returns null, as getValue() does, and
DefaultParserTest's testPropertiesDoNotChangeRegisteredOption() asserts
it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant