Invalid Date: header from remote server shouldn't cause null pointer exception
------------------------------------------------------------------------------

                 Key: SHINDIG-445
                 URL: https://issues.apache.org/jira/browse/SHINDIG-445
             Project: Shindig
          Issue Type: Improvement
          Components: Gadget Rendering Server (Java)
            Reporter: John Hjelmstad
            Priority: Minor


I've recently encountered a server which returns an invalid HTTP/1.1 Date 
header:
Date: Thu, 10 Jul 2008 22:54:20 EDT

Per (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1), Date must 
be specified in GMT. Shindig's implementation is in line with this requirement.

Shindig Java's implementation causes an NPE with this input due to the 
following code:
DateUtil.java:
  public static Date parseDate(String dateStr) {
    try {
      return rfc1123DateFormat.parseDateTime(dateStr).toDate();
    } catch (Exception e) {
      // Don't care.
      return null;
    }
  }

Used here:
  return DateUtil.parseDate(date).getTime();

I'm inclined to give poor caching characteristics to such inputs rather than 
NPE altogether, which offers a poor/confusing developer experience, in 
particular returning 0 when the Date returned from parseDate is invalid. 
Thoughts?


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to