Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6791927
Votes 0
Synopsis Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
Category java:classes_net
Reported Against
Release Fixed 7(b48)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs
Submit Date 09-JAN-2009
Description
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 :
 customer  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);
                                                                                                            ^^^^^^^^^^^
Posted Date : 2009-01-09 09:39:11.0
Work Around
N/A
Evaluation
Good catch. Indeed the Locale should be specifically added since cookies have to conform to US date format.
Will fix as soon as possible.
Posted Date : 2009-01-27 15:29:19.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang