Details
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8018869 | 7u45 | Neil Richards | P4 | Closed | Fixed | b01 |
JDK-2226592 | 7u40 | Edvard Wendelin | P4 | Closed | Fixed | b01 |
Description
OPERATING SYSTEM
----------------
All
FULL JDK VERSION
----------------
All Java 6
PROBLEM DESCRIPTION
-------------------
The JavaDoc of the add(URI uri, HttpCookie cookie) method of java.net.CookieStore indicates that null is an acceptable value for the URI parameter:
"uri - the uri this cookie associated with. if null, this cookie will
not be associated with an URI"
http://java.sun.com/javase/6/docs/api/java/net/CookieStore.html#add(java.net.URI,%20java.net.HttpCookie
However, calling this method with null URI is causes a NullPointerException:
java.lang.NullPointerException
at sun.net.www.protocol.http.InMemoryCookieStore.getEffectiveURI(Unknown Source)
at sun.net.www.protocol.http.InMemoryCookieStore.add(Unknown Source)
at Main.main(Main.java:44)
REPRODUCTION INSTRUCTIONS
-------------------------
Compile and run the testcase provided.
TESTCASE
--------
import java.net.CookieManager;
import java.net.CookieStore;
import java.net.HttpCookie;
public class CookieTest {
public static void main(String[] args) {
//get a cookie store implementation and add a cookie to the store with null URI
CookieStore cookieStore = (new CookieManager()).getCookieStore();
cookieStore.add(null, new HttpCookie("MY_COOKIE", "MY_COOKIE_VALUE"));
}
}
----------------
All
FULL JDK VERSION
----------------
All Java 6
PROBLEM DESCRIPTION
-------------------
The JavaDoc of the add(URI uri, HttpCookie cookie) method of java.net.CookieStore indicates that null is an acceptable value for the URI parameter:
"uri - the uri this cookie associated with. if null, this cookie will
not be associated with an URI"
http://java.sun.com/javase/6/docs/api/java/net/CookieStore.html#add(java.net.URI,%20java.net.HttpCookie
However, calling this method with null URI is causes a NullPointerException:
java.lang.NullPointerException
at sun.net.www.protocol.http.InMemoryCookieStore.getEffectiveURI(Unknown Source)
at sun.net.www.protocol.http.InMemoryCookieStore.add(Unknown Source)
at Main.main(Main.java:44)
REPRODUCTION INSTRUCTIONS
-------------------------
Compile and run the testcase provided.
TESTCASE
--------
import java.net.CookieManager;
import java.net.CookieStore;
import java.net.HttpCookie;
public class CookieTest {
public static void main(String[] args) {
//get a cookie store implementation and add a cookie to the store with null URI
CookieStore cookieStore = (new CookieManager()).getCookieStore();
cookieStore.add(null, new HttpCookie("MY_COOKIE", "MY_COOKIE_VALUE"));
}
}
Attachments
Issue Links
- backported by
-
JDK-2226592 CookieStore.add() cannot handle null URI parameter, contrary to the API specification
-
- Closed
-
-
JDK-8018869 CookieStore.add() cannot handle null URI parameter, contrary to the API specification
-
- Closed
-