http-client-branch: add note about mutability to HttpHeadersImpl http-client-branch
authorchegar
Mon, 26 Feb 2018 18:16:46 +0000
branchhttp-client-branch
changeset 56185 f195e5048667
parent 56184 1c7b4d7140e2
child 56186 261b5b524dd3
http-client-branch: add note about mutability to HttpHeadersImpl
src/java.net.http/share/classes/jdk/internal/net/http/common/HttpHeadersImpl.java
--- a/src/java.net.http/share/classes/jdk/internal/net/http/common/HttpHeadersImpl.java	Mon Feb 26 17:57:43 2018 +0000
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/common/HttpHeadersImpl.java	Mon Feb 26 18:16:46 2018 +0000
@@ -30,11 +30,14 @@
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.TreeMap;
 
 /**
  * Implementation of HttpHeaders.
+ *
+ * The public HttpHeaders API provides a read-only view, while the
+ * non-HttpHeaders members allow for implementation specific mutation, e.g.
+ * during creation, etc.
  */
 public class HttpHeadersImpl extends HttpHeaders {
 
@@ -49,7 +52,7 @@
         return Collections.unmodifiableMap(headers);
     }
 
-    // package private mutators
+    // non-HttpHeaders private mutators
 
     public HttpHeadersImpl deepCopy() {
         HttpHeadersImpl h1 = new HttpHeadersImpl();
@@ -66,7 +69,8 @@
     }
 
     public void setHeader(String name, String value) {
-        List<String> values = new ArrayList<>(1); // most headers has one value
+        // headers typically have one value
+        List<String> values = new ArrayList<>(1);
         values.add(value);
         headers.put(name, values);
     }