FULL PRODUCT VERSION :
C:\Programme\Java\jdk1.6.0_11\bin>java -version
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Class: java.net.HttpCookie
Method: private long expiryDate2DeltaSeconds(String dateString)
the method has following implementation:
SimpleDateFormat df =
new SimpleDateFormat(NETSCAPE_COOKIE_DATE_FORMAT);
df.setTimeZone(TimeZone.getTimeZone("GMT"));
so it's using the default Location (in gemany the Locale for germany)
BUT:
the expire attribute for a cookie is given in english or like that:
Sat, ....
this causes the "df.parse(dateString);" in an exception
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use the handling cookie framework in a none US Locale and get a Cookie with an expires value in english format
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
the
try {
Date date = df.parse(dateString);
return (date.getTime() - whenCreated) / 1000;
} catch (Exception e) {
return 0;
}
shouldn't run in exception block
ACTUAL -
the exception block is called, so the method returns the "exception" value
ERROR MESSAGES/STACK TRACES THAT OCCUR :
exception isn't thrown, but the function returns 0 instead of the long value
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
don't know - you made the HttpCookie final
maybe help would be:
SimpleDateFormat df = new SimpleDateFormat(NETSCAPE_COOKIE_DATE_FORMAT, Locale.US);
^^^^^^^^^^^