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

(cal) calling add() on a deserialized Calendar causes a NullPointerException

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P4
    • None
    • 5.0
    • core-libs

    Description

      FULL PRODUCT VERSION :
      java version "1.5.0_06"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      MS Windowx XP 5.1.2600

      A DESCRIPTION OF THE PROBLEM :
      If a GregorianCalendar object is created, serialized, and then deserialized, add() no longer functions as expected. It throws a NullPointerException one level down the call stack at getCurrentFixedDate(GregorianCalendar.java:2833). This appears to be the same as bug report 6365360, which for some reason is marked as closed despite not being fixed (the "release fixed" appears to be an older release, in which this bug was not present - it appears to be unique to 1.5).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a GregorianCalendar object.
      serialize the GregorianCalendar
      deserialize the GregorianCalendar
      attempt to add to it using DAY_OF_WEEK or DAY_OF_MONTH as the field (I haven't tested other fields, but I'm fairly certain MONTH doesn't cause the problem).

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      the date represented by the calendar should advance by one day
      ACTUAL -
      the call fails with NullPointerException

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.NullPointerException
      java.util.GregorianCalendar.getCurrentFixedDate(GregorianCalendar.java:2833)
      java.util.GregorianCalendar.add(GregorianCalendar.java:964)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      please see bug ID 6365360 for source code to reproduce this problem.
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
        Bug ID 6365360 suggests copying the calendar to a new instance.

      Attachments

        Issue Links

          Activity

            People

              okutsu Masayoshi Okutsu
              okutsu Masayoshi Okutsu
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: