Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8177418

NPE is not apparent for methods in java.util.TimeZone API docs

XMLWordPrintable

    • b08
    • generic
    • generic
    • Verified

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      At line 778 class TimeZone.java

      Method is a private static used from TimeZone.getTimezone(String)

      at this point when String is NULL enter to block to perform parseCustomTimeZone but with Null string NullPointer is raise

      if ((length = id.length()) < (GMT_ID_LENGTH + 2) ||
          id.indexOf(GMT_ID) != 0) {
          return null;
      }



      REPRODUCIBILITY :
      This bug can be reproduced always.

      When their input is null, the following methods in java.util.TimeZone throw a NullPointerException:

      TimeZone.getTimeZone(String ID)
      TimeZone.setID(String ID)
      TimeZone.inDaylightTime(Date date)

      The javadocs need to be updated to make this apparent. In addition, for the non static methods, it needs to be apparent that the methods "may throw" an NPE not "will throw"
      due to the possible existence of external sub-classes overriding these methods.

            jlu Justin Lu
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: