< prev index next >
src/java.base/share/classes/java/net/InMemoryCookieStore.java
Print this page
@@ -60,13 +60,13 @@
/**
* The default ctor
*/
public InMemoryCookieStore() {
- cookieJar = new ArrayList<HttpCookie>();
- domainIndex = new HashMap<String, List<HttpCookie>>();
- uriIndex = new HashMap<URI, List<HttpCookie>>();
+ cookieJar = new ArrayList<>();
+ domainIndex = new HashMap<>();
+ uriIndex = new HashMap<>();
lock = new ReentrantLock(false);
}
/**
@@ -113,11 +113,11 @@
// argument can't be null
if (uri == null) {
throw new NullPointerException("uri is null");
}
- List<HttpCookie> cookies = new ArrayList<HttpCookie>();
+ List<HttpCookie> cookies = new ArrayList<>();
boolean secureLink = "https".equalsIgnoreCase(uri.getScheme());
lock.lock();
try {
// check domainIndex first
getInternal1(cookies, domainIndex, uri.getHost(), secureLink);
@@ -155,11 +155,11 @@
/**
* Get all URIs, which are associated with at least one cookie
* of this cookie store.
*/
public List<URI> getURIs() {
- List<URI> uris = new ArrayList<URI>();
+ List<URI> uris = new ArrayList<>();
lock.lock();
try {
Iterator<URI> it = uriIndex.keySet().iterator();
while (it.hasNext()) {
@@ -279,11 +279,11 @@
private void getInternal1(List<HttpCookie> cookies, Map<String, List<HttpCookie>> cookieIndex,
String host, boolean secureLink) {
// Use a separate list to handle cookies that need to be removed so
// that there is no conflict with iterators.
- ArrayList<HttpCookie> toRemove = new ArrayList<HttpCookie>();
+ ArrayList<HttpCookie> toRemove = new ArrayList<>();
for (Map.Entry<String, List<HttpCookie>> entry : cookieIndex.entrySet()) {
String domain = entry.getKey();
List<HttpCookie> lst = entry.getValue();
for (HttpCookie c : lst) {
if ((c.getVersion() == 0 && netscapeDomainMatches(domain, host)) ||
@@ -366,11 +366,11 @@
// there may already have the same cookie, so remove it first
cookies.remove(cookie);
cookies.add(cookie);
} else {
- cookies = new ArrayList<HttpCookie>();
+ cookies = new ArrayList<>();
cookies.add(cookie);
indexStore.put(index, cookies);
}
}
}
< prev index next >