Return-Path: X-Original-To: apmail-curator-commits-archive@minotaur.apache.org Delivered-To: apmail-curator-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5AA3717BE1 for ; Tue, 21 Apr 2015 23:06:59 +0000 (UTC) Received: (qmail 85194 invoked by uid 500); 21 Apr 2015 23:06:59 -0000 Delivered-To: apmail-curator-commits-archive@curator.apache.org Received: (qmail 85123 invoked by uid 500); 21 Apr 2015 23:06:59 -0000 Mailing-List: contact commits-help@curator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@curator.apache.org Delivered-To: mailing list commits@curator.apache.org Received: (qmail 84031 invoked by uid 99); 21 Apr 2015 23:06:58 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Apr 2015 23:06:58 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 833E8E0E57; Tue, 21 Apr 2015 23:06:58 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: cammckenzie@apache.org To: commits@curator.apache.org Date: Tue, 21 Apr 2015 23:07:24 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [27/50] curator git commit: TreeCache: Fix case where root is deleted and recraated. TreeCache: Fix case where root is deleted and recraated. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/febfceca Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/febfceca Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/febfceca Branch: refs/heads/CURATOR-154 Commit: febfceca0b7409136a16d51d211212dea621cdc5 Parents: d3c5c36 Author: Scott Blum Authored: Fri Jan 16 00:24:14 2015 -0500 Committer: Scott Blum Committed: Fri Jan 16 00:24:14 2015 -0500 ---------------------------------------------------------------------- .../framework/recipes/cache/TreeCache.java | 2 +- .../framework/recipes/cache/TestTreeCache.java | 24 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/febfceca/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 fbe51df..41fc574 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 @@ -292,7 +292,7 @@ public class TreeCache implements Closeable if ( parent == null ) { // Root node; use an exist query to watch for existence. - client.checkExists().usingWatcher(this).inBackground().forPath(path); + client.checkExists().usingWatcher(this).inBackground(this).forPath(path); } else { http://git-wip-us.apache.org/repos/asf/curator/blob/febfceca/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java index 394428e..467f32b 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java @@ -325,6 +325,30 @@ public class TestTreeCache extends BaseTestTreeCache } @Test + public void testDeleteThenCreateRoot() throws Exception + { + client.create().forPath("/test"); + client.create().forPath("/test/foo", "one".getBytes()); + + cache = newTreeCacheWithListeners(client, "/test/foo"); + cache.start(); + assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/foo"); + assertEvent(TreeCacheEvent.Type.INITIALIZED); + + client.delete().forPath("/test/foo"); + assertEvent(TreeCacheEvent.Type.NODE_REMOVED, "/test/foo"); + client.create().forPath("/test/foo", "two".getBytes()); + assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/foo"); + + client.delete().forPath("/test/foo"); + assertEvent(TreeCacheEvent.Type.NODE_REMOVED, "/test/foo"); + client.create().forPath("/test/foo", "two".getBytes()); + assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/foo"); + + assertNoMoreEvents(); + } + + @Test public void testKilledSession() throws Exception { client.create().forPath("/test");