CURATOR-431 - Clean up stat population CURATOR-431 master
authorCam McKenzie <cammckenzie@apache.org>
Tue, 12 Sep 2017 23:48:18 +0000 (09:48 +1000)
committerCam McKenzie <cammckenzie@apache.org>
Tue, 12 Sep 2017 23:48:18 +0000 (09:48 +1000)
-Modified the population of the stat object to use DataTree#copyStat()

curator-framework/src/main/java/org/apache/curator/framework/imps/CreateBuilderImpl.java

index f796584..b2a3fbc 100644 (file)
@@ -38,6 +38,8 @@ import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.Op;
 import org.apache.zookeeper.data.ACL;
 import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.DataTree;
+
 import java.util.List;
 import java.util.UUID;
 import java.util.concurrent.Callable;
@@ -640,17 +642,7 @@ public class CreateBuilderImpl implements CreateBuilder, CreateBuilder2, Backgro
 
                     if ( (stat != null) && (storingStat != null) )
                     {
-                        storingStat.setAversion(stat.getAversion());
-                        storingStat.setCtime(stat.getCtime());
-                        storingStat.setCversion(stat.getCversion());
-                        storingStat.setCzxid(stat.getCzxid());
-                        storingStat.setDataLength(stat.getDataLength());
-                        storingStat.setEphemeralOwner(stat.getEphemeralOwner());
-                        storingStat.setMtime(stat.getMtime());
-                        storingStat.setMzxid(stat.getMzxid());
-                        storingStat.setNumChildren(stat.getNumChildren());
-                        storingStat.setPzxid(stat.getPzxid());
-                        storingStat.setVersion(stat.getVersion());
+                        DataTree.copyStat(stat, storingStat);
                     }
 
                     if ( (rc == KeeperException.Code.NONODE.intValue()) && createParentsIfNeeded )
@@ -1215,17 +1207,7 @@ public class CreateBuilderImpl implements CreateBuilder, CreateBuilder2, Backgro
                                     Stat setStat = client.getZooKeeper().setData(path, data, setDataIfExistsVersion);
                                     if(storingStat != null)
                                     {
-                                        storingStat.setAversion(setStat.getAversion());
-                                        storingStat.setCtime(setStat.getCtime());
-                                        storingStat.setCversion(setStat.getCversion());
-                                        storingStat.setCzxid(setStat.getCzxid());
-                                        storingStat.setDataLength(setStat.getDataLength());
-                                        storingStat.setEphemeralOwner(setStat.getEphemeralOwner());
-                                        storingStat.setMtime(setStat.getMtime());
-                                        storingStat.setMzxid(setStat.getMzxid());
-                                        storingStat.setNumChildren(setStat.getNumChildren());
-                                        storingStat.setPzxid(setStat.getPzxid());
-                                        storingStat.setVersion(setStat.getVersion());
+                                        DataTree.copyStat(setStat, storingStat);
                                     }
                                     createdPath = path;
                                 }