7045655: An empty InMemoryCookieStore should not return true for removeAll

CookieStore.removeAll() should return false for an empty CookieStore

Reviewed-by: chegar
This commit is contained in:
Kurchi Subhra Hazra 2012-03-15 13:21:16 -07:00
parent baec1b577c
commit 56132c0447
2 changed files with 10 additions and 1 deletions

View File

@ -207,6 +207,9 @@ class InMemoryCookieStore implements CookieStore {
public boolean removeAll() {
lock.lock();
try {
if (cookieJar.isEmpty()) {
return false;
}
cookieJar.clear();
domainIndex.clear();
uriIndex.clear();

View File

@ -23,8 +23,9 @@
/*
* @test
* @bug 6953455
* @bug 6953455 7045655
* @summary CookieStore.add() cannot handle null URI parameter
* and An empty InMemoryCookieStore should not return true for removeAll
*/
import java.net.CookieManager;
@ -44,6 +45,11 @@ public class NullUriCookieTest {
static void checkCookieNullUri() throws Exception {
//get a cookie store implementation and add a cookie to the store with null URI
CookieStore cookieStore = (new CookieManager()).getCookieStore();
//Check if removeAll() retrurns false on an empty CookieStore
if (cookieStore.removeAll()) {
fail = true;
}
checkFail("removeAll on empty store should return false");
HttpCookie cookie = new HttpCookie("MY_COOKIE", "MY_COOKIE_VALUE");
cookie.setDomain("foo.com");
cookieStore.add(null, cookie);