Commons CLI
  1. Commons CLI
  2. CLI-133

NullPointerException in Util.stripLeadingHyphens when passed a null argument

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor 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.

      1. bug133.patch
        3 kB
        Brian Egge

        Activity

        No work has yet been logged on this issue.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development