JDK-6646221 : CookieManager.get() doesn't work if uri.getPath() == ""
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 6u3
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_nevada
  • CPU: generic
  • Submitted: 2008-01-01
  • Updated: 2010-04-02
  • Resolved: 2008-04-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7Resolved
Related Reports
Duplicate :  
Description
If CookieManager.get() is called with an URI that does not contain a path, e.g "http://www.sun.com" instead of "http://www.sun.com/", it does not return any cookies, even if CookieManager contains cookies for the URI.

The relevant code is:

    /*
     * path-matches algorithm, as defined by RFC 2965
     */
    private boolean pathMatches(String path, String pathToMatchWith) {
        if (path == pathToMatchWith)
            return true;
        if (path == null || pathToMatchWith == null)
            return false;
        if (path.startsWith(pathToMatchWith))
            return true;

        return false;
    }

That needs to cater for the case where path is the empty string.

Comments
EVALUATION There is a "Cookie management issues" bucket CR (6644726) which now includes that particular issue, among a few others. Therefore closing as a duplicate.
08-04-2008

EVALUATION A cookie should not have a null path. By default, when no path is specified, it should be set to the directory of the associated URI. So the problem is more in the way HttpCookie parsing is done than in the get() method. Will fix in JDK 7.
26-02-2008