< prev index next >
src/java.base/share/classes/java/net/CookieManager.java
Print this page
@@ -199,14 +199,13 @@
// pre-condition check
if (uri == null || requestHeaders == null) {
throw new IllegalArgumentException("Argument is null");
}
- Map<String, List<String>> cookieMap = new java.util.HashMap<>();
// if there's no default CookieStore, no way for us to get any cookie
if (cookieJar == null)
- return Collections.unmodifiableMap(cookieMap);
+ return Map.of();
boolean secureLink = "https".equalsIgnoreCase(uri.getScheme());
List<HttpCookie> cookies = new java.util.ArrayList<>();
String path = uri.getPath();
if (path == null || path.isEmpty()) {
@@ -242,12 +241,11 @@
}
// apply sort rule (RFC 2965 sec. 3.3.4)
List<String> cookieHeader = sortByPath(cookies);
- cookieMap.put("Cookie", cookieHeader);
- return Collections.unmodifiableMap(cookieMap);
+ return Map.of("Cookie", cookieHeader);
}
public void
put(URI uri, Map<String, List<String>> responseHeaders)
throws IOException
< prev index next >