JDK-7192951 : (tz) /etc/timezone handling, allow more flexible format and fallback
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: other
  • CPU: other
  • Submitted: 2012-08-21
  • Updated: 2013-04-05
  • Resolved: 2013-02-14
Related Reports
Duplicate :  
Relates :  
Description
This is a SUNBUG for 100206: https://bugs.openjdk.java.net/show_bug.cgi?id=100206

Hello,

Today I found that one computer jvm Calendar behaves differently than another
computer. Took me quite a while to figure out what is wrong.

The root cause was a comment in /etc/timezone which led the jvm to try and open
the comment as a file, fails and did not fallback to next method.

I know that there is a comment which explicitly assume no comments, no spaces
etc... but it is so simple to accept such standard format. Attached is a patch,
please consider to apply.

Another issue is that if I remove the /etc/timezone file, the jvm works as
expected, so maybe if the content of the /etc/timezone is an invalid, the jvm
should fallback to other methods.

Thanks!

TimeZone_md.c.diff attached to this report.

Comments
I'm closing this one. If comments support becomes the spec of the file format, please reopen.
14-02-2013

EVALUATION Here's what I got as the "spec" of /etc/timezone from a Debian person. ===================================================================== I am not sure that a formal spec of /etc/timezone exists. The Debian tools for manipulating it (tzconfig and tzsetup) do basically the same thing. --- reading --- if [ -L /etc/localtime ] ; then current_timezone=$(readlink /etc/localtime | sed 's%^/usr/share/zoneinfo/%%') elif [ -f /etc/timezone ] && [ -f /etc/localtime ]; then current_timezone=$(cat /etc/timezone) fi --- setting --- echo $timezone > /etc/timezone It is the same in Ubuntu. So, in Debian-based distros it is just a LF-terminated line, with no spaces and extra characters. To be a little more general, I suggest ignoring all leading spaces (including new lines) and then reading consecutive non-space characters. =====================================================================
24-08-2012