-
Bug
-
Resolution: Fixed
-
P3
-
5.0, 6, 6u10
-
b72
-
x86
-
linux
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2180391 | 6u18 | Masayoshi Okutsu | P3 | Resolved | Fixed | b02 |
JDK-2186160 | OpenJDK6 | Yuka Kamiya | P3 | Resolved | Fixed | b18 |
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_06-b05, mixed mode)
Bug also observed on 1.5.0_07.
ADDITIONAL OS VERSION INFORMATION :
Red Hat Enterprise Linux AS release 4 (Nahant Update 2)
Linux 2.6.9-22.20.ELsmp #1 SMP Fri Nov 18 03:04:44 EST 2005 x86_64 x86_64 x86_64 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
Time zone is set to America/New_York, and the system time should be within the EDT period
A DESCRIPTION OF THE PROBLEM :
We have three identical Linux server and when we run the test case included below, the time reported by the machines are different.
By examining the available JVM source code, I noticed that the logic that works out the default timezone on Linux is incorrect.
The way JVM works out the default timezone is as follows:
1) Looks to environment variable TZ
This is not set in our linux box
2) JVM looks for the file /etc/sysconfig/clock and tries to find the "ZONE" entry.
However, on these host the ZONE entry does not have a double quote around the actual variable, and the JVM code is unable to recongise the entry.
3) If the ZONE entry is not found, the JVM will compare contents fo /etc/localtime with the contents of every file in /usr/share/zoneinfo recursively. When the contents matches, it returns the path and filename, referenced from /usr/share/zoneinfo
On our machine, there are three files in /usr/share/zoneinfo that matches /etc/localtime (these files are standard on RHEL4 machines):
/usr/share/zoneinfo/America/New_York
/usr/share/zoneinfo/posixrules
/usr/share/zoneinfo/EST5EDT
What happens is that depends on the way OS transverse the filesystem, the name that JVM get can be different. On the box that fail the test, the jvm actually found posixrules file first, which means that the JVM thinks the timezone is "posixrules". The JVM will then attempt to look up timezone mapping in <java.home>/jre/lib/zi directory, and it will fail the find the timezone. So it will revert to the default GMT+offset timezone id as a fail safe, which does not take into the account for daylight saving.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
We have three identical Linux server and ran the test case included below, the time reported by the machine is different.
(host 1)
bash-3.00$ date ; /opt/sunjava-1.5.0_06/jre/bin/java simpleTest
Tue Aug 1 14:43:25 EDT 2006
Simple test Josh
TIME ZONE :GMT-05:00
Value of milliseconds since Epoch is 1154457805659
Value of s in readable format is Tue Aug 01 13:43:25 GMT-05:00 2006
(host 2)
bash-3.00$ date ; /opt/sunjava-1.5.0_06/jre/bin/java simpleTest
Tue Aug 1 14:43:36 EDT 2006
Simple test Josh
TIME ZONE :Eastern Standard Time
Value of milliseconds since Epoch is 1154457816528
Value of s in readable format is Tue Aug 01 14:43:36 EDT 2006
Notice that the default timezone returned by the systems are different.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The testcase should show the same time in readable format (like host 2)
ACTUAL -
During EDT, the printed time could be different from what we are expecting
REPRODUCIBILITY :
This bug can be reproduced occasionally.
---------- BEGIN SOURCE ----------
import java.util.*;
import java.text.*;
class simpleTest
{
public static void main(String args[])
{
System.out.println("Simple test Josh ");
Date now = new Date();
DateFormat df = DateFormat.getDateInstance();
Calendar cal = Calendar.getInstance();
System.out.println("\n TIME ZONE :"+ cal.getTimeZone().getDisplayName());
long nowLong = now.getTime();
String s = now.toString();
System.out.println("Value of milliseconds since Epoch is " + nowLong);
System.out.println("Value of s in readable format is " + s);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
1) Set TZ to the correct timezone
2) pass -Duser.timezone with the correct timezone
3) make sure /etc/sysconfig/clock ZONE variable has quote around the value
- backported by
-
JDK-2180391 (tz) Default timezone is incorrectly set occasionally on Linux
-
- Resolved
-
-
JDK-2186160 (tz) Default timezone is incorrectly set occasionally on Linux
-
- Resolved
-
- duplicates
-
JDK-6609348 Incorrect "US/Pacific" timezone detection when /etc/localtime is not a link
-
- Closed
-
-
JDK-6626679 (tz) Java 6 SE sometimes exhibit incorrect time zone
-
- Closed
-
-
JDK-6893624 JAVA DST is wrong with America/New York
-
- Closed
-
-
JDK-2179642 (tz) Date is off by an hour on Linux
-
- Closed
-
-
JDK-6645293 (tz) Date is off by an hour on Linux
-
- Closed
-
- relates to
-
JDK-6533916 (tz) regression test java/util/TimeZone/LinuxTZVM.sh on RH EL 4
-
- Closed
-
-
JDK-6856174 Test closed/java/util/TimeZone/Bug4472183.java does not work on Linux, TimeZone.getDefault fails
-
- Open
-
-
JDK-7149608 (tz): Default TZ detection fails on linux when symbolic links to non default location used.
-
- Resolved
-
-
JDK-8345213 JVM Prefers /etc/timezone Over /etc/localtime on Debian 12
-
- Resolved
-
-
JDK-7192951 (tz) /etc/timezone handling, allow more flexible format and fallback
-
- Closed
-