Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-14115

SimpleDateFormatter's are construted w/default Locale, causing malformed dates on some platforms

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      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...

            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));
      

      ...which can cause invalid expiration attributes in the Set-Cookies header like this (as noted by http-commons's ResponseProcessCookies class...

      WARN: Invalid cookie header: "Set-Cookie: hadoop.auth=; Path=/; Domain=127.0.0.1; Expires=Ara, 01-Sa-1970 00:00:00 GMT; HttpOnly". Invalid 'expires' attribute: Ara, 01-Sa-1970 00:00:00 GMT
      

      There are very likely many other places in the hadoop code base where the default Locale is being unintentionally used when formatting Dates/Numbers.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                hossman Chris M. Hostetter
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: