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:26:32 UTC

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

Author: rgs
Date: Thu Jun  4 16:26:32 2015
New Revision: 1683588

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

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

Modified: zookeeper/branches/branch-3.5/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.5/CHANGES.txt?rev=1683588&r1=1683587&r2=1683588&view=diff
==============================================================================
--- zookeeper/branches/branch-3.5/CHANGES.txt (original)
+++ zookeeper/branches/branch-3.5/CHANGES.txt Thu Jun  4 16:26:32 2015
@@ -111,6 +111,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-1660 Documentation for Dynamic Reconfiguration (Reed Wanderman-Milne via shralex)
 

Modified: zookeeper/branches/branch-3.5/src/java/main/org/apache/zookeeper/server/DataNode.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.5/src/java/main/org/apache/zookeeper/server/DataNode.java?rev=1683588&r1=1683587&r2=1683588&view=diff
==============================================================================
--- zookeeper/branches/branch-3.5/src/java/main/org/apache/zookeeper/server/DataNode.java (original)
+++ zookeeper/branches/branch-3.5/src/java/main/org/apache/zookeeper/server/DataNode.java Thu Jun  4 16:26:32 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;
@@ -124,7 +125,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);
     }
 
     public synchronized long getApproximateDataSize() {