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

ZoneId.systemDefault() doesn't reflect the change of system default time-zone because of cache

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      According to https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/ZoneId.html#systemDefault(), it should be true, that "If the system default time-zone is changed, then the result of this method will also change."

      This buggy (?) behavior was probably introduced with the following optimization:
      https://bugs.openjdk.org/browse/JDK-8074002

      I think that either implementation or javadoc should be fixed.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run jshell, invoke ZoneId.systemDefault():
      jshell> java.time.ZoneId.systemDefault()
      => Initial/Timezone

      Do not close jshell!

      2. In parallel, change system time zone:
      $ sudo timedatectl set-timezone Other/Timezone

      3. Go back to jshell, invoke ZoneId.systemDefault() again:
      jshell> java.time.ZoneId.systemDefault()


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      => Other/Timezone
      ACTUAL -
      => Initial/Timezone

            naoto Naoto Sato
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: