hadoop-common-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hoss Man (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HADOOP-14115) SimpleDateFormatter's are construted w/default Locale, causing malformed dates on some platforms
Date Thu, 23 Feb 2017 21:59:44 GMT

    [ https://issues.apache.org/jira/browse/HADOOP-14115?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15881366#comment-15881366

Hoss Man commented on HADOOP-14115:

It would be irresponsible of me not to urge the hadoop community to consider using the following
tools for helping to prevent/diagnose these types of bugs...

* https://github.com/policeman-tools/forbidden-apis/wiki
** to identify places in the code where {{java.lang.*}} methods are used that implicitly the
default Locale
* https://labs.carrotsearch.com/randomizedtesting.html
** to randomize the Locale (and other platform defaults) used when running automated tests.

...the Lucene community finds them invaluable.

> SimpleDateFormatter's are construted w/default Locale, causing malformed dates on some
> ------------------------------------------------------------------------------------------------
>                 Key: HADOOP-14115
>                 URL: https://issues.apache.org/jira/browse/HADOOP-14115
>             Project: Hadoop Common
>          Issue Type: Bug
>            Reporter: Hoss Man
> In at least one place I know of in Hadoop, {{SimpleDateFormatter}} is used to serialize
{{Date}} object in a format intended for machine consumption -- and should be following strict
formatting rules -- but the {{SimpleDateFormatter}}  instance is not constructed with an explicit
{{Locale}} so the platform default is used instead.  This causes things like "Day name in
week" ({{E}}) to generate unexpected results depending on the Locale of the machine where
the code is running, resulting in date-time strings that violate the formatting rules.
> A specific example of this is {{AuthenticationFilter.createAuthCookie}} which has code
that looks like this...
> {code}
>       Date date = new Date(expires);
>       SimpleDateFormat df = new SimpleDateFormat("EEE, " +
>               "dd-MMM-yyyy HH:mm:ss zzz");
>       df.setTimeZone(TimeZone.getTimeZone("GMT"));
>       sb.append("; Expires=").append(df.format(date));
> {code}
> ...which can cause invalid expiration attributes in the {{Set-Cookies}} header like this
(as noted by http-commons's {{ResponseProcessCookies}} class...
> {noformat}
> WARN: Invalid cookie header: "Set-Cookie: hadoop.auth=; Path=/; Domain=; Expires=Ara,
01-Sa-1970 00:00:00 GMT; HttpOnly". Invalid 'expires' attribute: Ara, 01-Sa-1970 00:00:00
> {noformat}
> There are very likely many other places in the hadoop code base where the default {{Locale}}
is being unintentionally used when formatting Dates/Numbers.

This message was sent by Atlassian JIRA

To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org

View raw message