JDK-8015799 : HttpURLConnection.getHeaderFields() throws IllegalArgumentException: Empty cookie header string
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2013-06-03
  • Updated: 2014-10-03
  • Resolved: 2013-06-28
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 8
8 b98Fixed
Related Reports
Relates :  
Description
If a program installs the default cookie handler, opens an HttpURLConnection to http://www.walmart.com/msharbor/, and attempts to call HttpURLConnection.getHeaderFields() on that connection, HttpURLConnection.getHeaderFields() unexpectedly throws the following exception:

Exception in thread "main" java.lang.IllegalArgumentException: Empty cookie header string
	at java.net.HttpCookie.parseInternal(HttpCookie.java:828)
	at java.net.HttpCookie.parse(HttpCookie.java:204)
	at java.net.HttpCookie.access$100(HttpCookie.java:58)
	at java.net.HttpCookie$12.parse(HttpCookie.java:979)
	at sun.net.www.protocol.http.HttpURLConnection.filterHeaderField(HttpURLConnection.java:2632)
	at sun.net.www.protocol.http.HttpURLConnection.getFilteredHeaderFields(HttpURLConnection.java:2669)
	at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(HttpURLConnection.java:2713)
	at emptycookieheaderstringtest.EmptyCookieHeaderStringTest.main(EmptyCookieHeaderStringTest.java:17)

To reproduce, compile and run the following program (with -DproxyHost=<proxy> -DproxyPort=<port>, if you are behind a proxy):

public class EmptyCookieHeaderStringTest {
    public static void main(String[] args) throws IOException {
        CookieHandler.setDefault(new TestCookieHandler());
        URL url = new URL("http://www.walmart.com/msharbor/");
        HttpURLConnection c = (HttpURLConnection) url.openConnection();
        c.getHeaderFields();        
    }
}

class TestCookieHandler extends CookieHandler {
    @Override
    public Map<String, List<String>> get(URI uri, Map<String, List<String>> requestHeaders) {
        return new HashMap<String, List<String>>();
    }

    @Override
    public void put(URI uri, Map<String, List<String>> responseHeaders) {
    }
}

The problem is the root cause for https://javafx-jira.kenai.com/browse/RT-30052 .
Comments
SQE verified on b100
26-07-2013