Uploaded image for project: 'Commons CLI'
  1. Commons CLI
  2. CLI-133

NullPointerException in Util.stripLeadingHyphens when passed a null argument

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0, 1.1
    • Fix Version/s: 1.1
    • Component/s: CLI-1.x
    • Labels:
      None

      Description

      If you try to do a hasOption(null), you get a NPE:

      java.lang.NullPointerException
      at org.apache.commons.cli.Util.stripLeadingHyphens(Util.java:39)
      at org.apache.commons.cli.CommandLine.resolveOption(CommandLine.java:166)
      at org.apache.commons.cli.CommandLine.hasOption(CommandLine.java:68)

      Either hasOption should reject the null argument, or the function should simply return false. I think the latter makes more since, as this is how Java collections generally work.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              brianegge Brian Egge
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: