Bug 1562837
Summary: | Setting the TZ environment variable breaks TimeZone in Java | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 8 | Reporter: | Deepu K S <dkochuka> |
Component: | java-1.8.0-openjdk | Assignee: | Andrew John Hughes <ahughes> |
Status: | CLOSED MIGRATED | QA Contact: | OpenJDK QA <java-qa> |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 8.2 | CC: | ahughes, cww, dbhole, jandrlik, jdoyle, jvanek, jwright, mmillson, vpakolu |
Target Milestone: | rc | Keywords: | MigratedToJIRA, Triaged |
Target Release: | 8.4 | ||
Hardware: | x86_64 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2023-09-12 21:51:43 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: | |||
Bug Depends On: | |||
Bug Blocks: | 1594286, 1894575 |
Description
Deepu K S
2018-04-02 16:29:15 UTC
Another test that we ran locally; # cat test.java class test { /** Print a hello message */ public static void main(String[] args) { System.out.println(java.util.TimeZone.getDefault()); } } # javac test.java # export TZ="/usr/share/zoneinfo/America/New_York" # java test sun.util.calendar.ZoneInfo[id="GMT-05:00",offset=-18000000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null] <<<<<<<<<---timezone id is set to GMT -05, it should be America/New_York. # unset TZ # java test sun.util.calendar.ZoneInfo[id="America/New_York",offset=-18000000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/New_York,offset=-18000000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]] If we export TZ to just the timezone as below, it works. # export TZ=":America/New_York" # java test sun.util.calendar.ZoneInfo[id="America/New_York",offset=-18000000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/New_York,offset=-18000000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]] The issue is seen when we export TZ to the absolute filepath or /etc/localtime. Below is the Bug that was opened Oracle Java BugZilla. https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8200722 Andrew, can you please provide a status update? Sorry, I mixed this up with a similar bug (bug 1536048) and thought I'd answered it. Looking over the code, I see the issue is that any value of TZ is assumed to be a zonename. So, America/New_York works, but if it's a file path, the path is sent back to the calling Java code unaltered, which can't match it to a zone and instead falls back to GMT. I believe different behaviour should be used if the TZ value starts with a '/' (or ':/', but it already just drops the ':') 1. If the path is /etc/localtime, use the existing logic to find out which zone that points to. 2. If it's a timezone path, use getZoneName to strip the beginning and return the zone name The logic for both these options is already there for the case where TZ is unset. It's just ignored where TZ is set, preferring to just use that value as is. A patch for this should be fairly trivial. Moving to RHEL 7.8. Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug. This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there. Due to differences in account names between systems, some fields were not replicated. Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information. To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer. You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like: "Bugzilla Bug" = 1234567 In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information. |