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

using Timezone Asia/Ho_Chi_Minh causes exception in Calendar.getTime()

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 7u65, 9
    • Fix Version/s: None
    • Component/s: core-libs

      Description

      FULL PRODUCT VERSION :
      java version "1.7.0_65"
      Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
      Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux larrylopez-wsl1 3.13.0-39-generic #66~precise1-Ubuntu SMP Wed Oct 29 09:56:49 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux




      EXTRA RELEVANT SYSTEM CONFIGURATION :
      The latest tzupdater.jar was applied: tzupdater-1.4.9-2014i

      A DESCRIPTION OF THE PROBLEM :
      Since the latest tzupdater-1.4.9-2014i was applied, we have had 26 cases of customers encountering exceptions in Calendar.getTime(), all using the timezone Asia/Ho_Chi_Minh

      We have had to rollback that timezone file(jre/lib/zi/Asia/Ho_Chi_Minh) to temporarily fix the issue.

      I tested all timezones and the following cause exceptions with the above code(all these are in the Asia/Ho_Chi_Minh file):
      Asia/Ho_Chi_Minh
      Asia/Saigon
      VST



      ADDITIONAL REGRESSION INFORMATION:
      This was working using the previous data before the tzupdater-1.4.9-2014i was applied.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Apply latest tzupdater.jar ( tzupdater-1.4.9-2014i )

      2. Compile and run this program to test all timezones:
      import java.text.DateFormat;
      import java.text.SimpleDateFormat;
      import java.util.Calendar;
      import java.util.Locale;
      import java.util.TimeZone;

      public class Main {

          public static void main(String[] args) {
              for(String tz: TimeZone.getAvailableIDs()) {
                  try {
                      test(tz);
                  }
                  catch(Exception e) {
                      System.out.println("failed: " + tz + " Exception: " + e);
                  }
              }
          }
          public static void test(String tz) {
              TimeZone brokenTimeZone = TimeZone.getTimeZone(tz);
              DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, new Locale("en"));
              df.setLenient(false);
              df.setTimeZone(brokenTimeZone);
              Calendar calendar = df.getCalendar();
              calendar.set(1959, Calendar.DECEMBER, 31, 23, 0);
              ((SimpleDateFormat)df).set2DigitYearStart(calendar.getTime());
          }
      }




      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No exceptions should be reported.
      ACTUAL -
      The following exceptions occur:
      failed: Asia/Ho_Chi_Minh Exception: java.lang.IllegalArgumentException: YEAR: 1959 -> 1960
      failed: Asia/Saigon Exception: java.lang.IllegalArgumentException: YEAR: 1959 -> 1960
      failed: VST Exception: java.lang.IllegalArgumentException: YEAR: 1959 -> 1960

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      failed: Asia/Ho_Chi_Minh Exception: java.lang.IllegalArgumentException: YEAR: 1959 -> 1960
      failed: Asia/Saigon Exception: java.lang.IllegalArgumentException: YEAR: 1959 -> 1960
      failed: VST Exception: java.lang.IllegalArgumentException: YEAR: 1959 -> 1960

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.text.DateFormat;
      import java.text.SimpleDateFormat;
      import java.util.Calendar;
      import java.util.Locale;
      import java.util.TimeZone;

      public class Main {

          public static void main(String[] args) {
              for(String tz: TimeZone.getAvailableIDs()) {
                  try {
                      test(tz);
                  }
                  catch(Exception e) {
                      System.out.println("failed: " + tz + " Exception: " + e);
                  }
              }
          }
          public static void test(String tz) {
              TimeZone brokenTimeZone = TimeZone.getTimeZone(tz);
              DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, new Locale("en"));
              df.setLenient(false);
              df.setTimeZone(brokenTimeZone);
              Calendar calendar = df.getCalendar();
              calendar.set(1959, Calendar.DECEMBER, 31, 23, 0);
              ((SimpleDateFormat)df).set2DigitYearStart(calendar.getTime());
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Change timezone to another like Asia/Bangkok or rollback jre/lib/zi/Asia/Ho_Chi_Minh file to previous version before tzupdater-1.4.9-2014i was applied.

        Attachments

          Activity

            People

            • Assignee:
              okutsu Masayoshi Okutsu
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: