Uploaded image for project: 'Pivot'
  1. Pivot
  2. PIVOT-577

Time.decode() throws NPE when no milliseconds present in input string

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: 2.0
    • Component/s: core-util
    • Labels:
      None
    • Environment:
      JDK 6 Update 21

      Description

      Time.decode("12:34:56.789");
      works,

      Time.decode("12:34:56")
      throws a NullPointerException at org.apache.pivot.util.Time.decode(Time.java:399)

      I believe the problem is that matcher.groupCount() returns # of groups in pattern, not # of matched, so it always ==5; thus when no milliseconds passed, matcher.group(4) is null.

      if (matcher.groupCount() == 5)

      { millisecond = Integer.parseInt(matcher.group(4).substring(1)); }

      else

      { millisecond = 0; }

        Attachments

          Activity

            People

            • Assignee:
              gbrown Gregory K. Brown
              Reporter:
              zorqie Ilian Pavlov
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: