8005598: (reopened) Need to clone array of input/output parameters
authorxuelei
Mon, 13 May 2013 06:05:32 -0700
changeset 17459 70a7c2c1383b
parent 17458 4252f06a378f
child 17460 19eb5d62770a
8005598: (reopened) Need to clone array of input/output parameters Reviewed-by: weijun
jdk/src/share/classes/com/sun/jndi/dns/DnsContext.java
jdk/src/share/classes/com/sun/jndi/ldap/BasicControl.java
--- a/jdk/src/share/classes/com/sun/jndi/dns/DnsContext.java	Mon May 13 05:41:51 2013 -0700
+++ b/jdk/src/share/classes/com/sun/jndi/dns/DnsContext.java	Mon May 13 06:05:32 2013 -0700
@@ -102,7 +102,7 @@
         this.domain = new DnsName(domain.endsWith(".")
                                   ? domain
                                   : domain + ".");
-        this.servers = servers;
+        this.servers = (servers == null) ? null : servers.clone();
         this.environment = (Hashtable<Object,Object>) environment.clone();
         envShared = false;
         parentIsDns = false;
@@ -129,11 +129,11 @@
      * no conflict.
      */
     private DnsContext(DnsContext ctx) {
-        environment = ctx.environment;
+        environment = ctx.environment;  // shared environment, copy-on-write
         envShared = ctx.envShared = true;
         parentIsDns = ctx.parentIsDns;
         domain = ctx.domain;
-        servers = ctx.servers;
+        servers = ctx.servers;          // shared servers, no write operation
         resolver = ctx.resolver;
         authoritative = ctx.authoritative;
         recursion = ctx.recursion;
--- a/jdk/src/share/classes/com/sun/jndi/ldap/BasicControl.java	Mon May 13 05:41:51 2013 -0700
+++ b/jdk/src/share/classes/com/sun/jndi/ldap/BasicControl.java	Mon May 13 06:05:32 2013 -0700
@@ -81,7 +81,7 @@
         this.id = id;
         this.criticality = criticality;
         if (value != null) {
-            this.value = value;
+            this.value = value.clone();
         }
     }