You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2014/07/31 17:03:24 UTC
[3/5] git commit: Fix event ordering on JDK 1.7
Fix event ordering on JDK 1.7
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/678e2002
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/678e2002
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/678e2002
Branch: refs/heads/CURATOR-33
Commit: 678e2002cdc060659e8ccd61f7ac95683781ab04
Parents: f31c1f9
Author: Scott Blum <sc...@squareup.com>
Authored: Thu Jul 24 06:24:37 2014 -0400
Committer: Scott Blum <sc...@squareup.com>
Committed: Thu Jul 24 06:24:37 2014 -0400
----------------------------------------------------------------------
.../framework/recipes/cache/TreeCache.java | 21 ++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/678e2002/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
index 735d5e7..f71c21d 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
@@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory;
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.SortedSet;
import java.util.concurrent.ConcurrentMap;
@@ -230,16 +231,24 @@ public class TreeCache implements Closeable
}
}
+ // Present new children in sorted order for test determinism.
+ List<String> newChildren = new ArrayList<String>();
for ( String child : event.getChildren() )
{
- String fullPath = ZKPaths.makePath(path, child);
if ( !childMap.containsKey(child) )
{
- TreeNode node = new TreeNode(fullPath, this);
- if ( childMap.putIfAbsent(child, node) == null )
- {
- node.wasCreated();
- }
+ newChildren.add(child);
+ }
+ }
+
+ Collections.sort(newChildren);
+ for ( String child : newChildren )
+ {
+ String fullPath = ZKPaths.makePath(path, child);
+ TreeNode node = new TreeNode(fullPath, this);
+ if ( childMap.putIfAbsent(child, node) == null )
+ {
+ node.wasCreated();
}
}
}