[ZEPPELIN-6483] Format HDFS modification time in GMT to match the printed label - #5351
Conversation
tbonelee
left a comment
There was a problem hiding this comment.
LGTM.
Verified locally with the mock WebHDFS interpreter under an Asia/Seoul default zone: the
/app-logs entry goes from 2015-08-03 05:43GMT to 2015-08-02 20:43GMT, which is what
modificationTime 1438548219672 actually is in GMT. Reverting only the listDate() change
makes the new test fail, so it pins the regression rather than just asserting current
behaviour. Formatting in GMT also matches existing practice here, e.g. KerberosRealm uses
the same SimpleDateFormat + setTimeZone(TimeZone.getTimeZone("GMT")) pattern.
One non-blocking nit, fine to leave for a follow-up: new SimpleDateFormat(pattern) still
takes its calendar and digits from the JVM default locale, so the same class of environment
dependence survives. Same pattern, same GMT zone, only the default locale changed:
en-US 2015-08-02 20:43
th-TH 2558-08-02 20:43 (Buddhist calendar)
ja-JP-u-ca-japanese 27-08-02 20:43 (Japanese era)
ar-SA ٢٠١٥-٠٨-٠٢ ٢٠:٤٣ (Arabic-Indic digits)
new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ROOT) closes that path too. Such JVM locales
are far rarer than non-UTC zones, so it is not a blocker.
|
Merged into master |
What is this PR for?
In the HDFS file interpreter,
listOne()appends a hard-codedGMTlabel to themodification time, but
listDate()formats the timestamp using the JVM defaulttime zone. On any server not running in UTC, the displayed value does not match
the label (e.g. a file modified at
2015-08-02 20:43GMT is shown as2015-08-03 05:43GMTon a KST server).This PR sets the formatter's time zone to GMT in
listDate()so the renderedvalue matches the existing label.
Why format in GMT (option A) rather than keep local time and fix the label (option B):
modificationTimeis an absolute epoch value, so the time zone is only adisplay choice. Formatting in GMT keeps the output identical regardless of the
host/JVM default zone and consistent with the label already printed.
remote-interpreter, multi-user setups ("whose local time?"), and the output
would vary per deployment, making it harder to reproduce and test.
What type of PR is it?
Bug Fix
Todos
listDate()Asia/Seoul) and asserts the value is rendered in GMT to match the labelWhat is the Jira issue?
How should this be tested?
./mvnw test -pl file -Dtest=HDFSFileInterpreterTesttestListDateFormatsInGmtToMatchLabelpins a knownmodificationTime(1438548219672 = 2015-08-02 20:43 GMT) under anAsia/Seouldefault zone and asserts the output contains2015-08-02 20:43GMT.Screenshots (if appropriate)
N/A
Questions: