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

NullPointerException in Util.stripLeadingHyphens when passed a null argument

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0, 1.1
    • 1.1
    • CLI-1.x
    • 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

        1. bug133.patch
          3 kB
          Brian Egge

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: