You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by rg...@apache.org on 2015/06/04 18:27:20 UTC

svn commit: r1683589 - in /zookeeper/branches/branch-3.4: CHANGES.txt src/java/main/org/apache/zookeeper/server/DataNode.java

Author: rgs
Date: Thu Jun  4 16:27:19 2015
New Revision: 1683589

URL: http://svn.apache.org/r1683589
Log:
ZOOKEEPER-2194: Let DataNode.getChildren() return an unmodifiable view of its
children set (Hitoshi Mitake via rgs)

Modified:
    zookeeper/branches/branch-3.4/CHANGES.txt
    zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/server/DataNode.java

Modified: zookeeper/branches/branch-3.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/CHANGES.txt?rev=1683589&r1=1683588&r2=1683589&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/CHANGES.txt (original)
+++ zookeeper/branches/branch-3.4/CHANGES.txt Thu Jun  4 16:27:19 2015
@@ -84,6 +84,9 @@ BUGFIXES:
   ZOOKEEPER-2096: C client builds with incorrect error codes in VisualStudio 2010+
   (Vitaly Stakhovsky via rgs)
 
+  ZOOKEEPER-2194: Let DataNode.getChildren() return an unmodifiable view of its children set
+  (Hitoshi Mitake via rgs)
+
 IMPROVEMENTS:
 
   ZOOKEEPER-1575. adding .gitattributes to prevent CRLF and LF mismatches for

Modified: zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/server/DataNode.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/server/DataNode.java?rev=1683589&r1=1683588&r2=1683589&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/server/DataNode.java (original)
+++ zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/server/DataNode.java Thu Jun  4 16:27:19 2015
@@ -21,6 +21,7 @@ package org.apache.zookeeper.server;
 import java.io.IOException;
 import java.util.HashSet;
 import java.util.Set;
+import java.util.Collections;
 
 import org.apache.jute.InputArchive;
 import org.apache.jute.OutputArchive;
@@ -128,7 +129,11 @@ public class DataNode implements Record
      * @return the children of this datanode
      */
     public synchronized Set<String> getChildren() {
-        return children;
+        if (children == null) {
+            return children;
+        }
+
+        return Collections.unmodifiableSet(children);
     }
 
     synchronized public void copyStat(Stat to) {