You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@curator.apache.org by GitBox <gi...@apache.org> on 2022/06/15 11:43:07 UTC

[GitHub] [curator] eolivelli commented on a diff in pull request #419: CURATOR-640: Run PathChildrenCache's & TreeCache's default thread isolated

eolivelli commented on code in PR #419:
URL: https://github.com/apache/curator/pull/419#discussion_r897876484


##########
curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java:
##########
@@ -1151,4 +1151,45 @@ public void invoke() throws Exception
             TestCleanState.closeAndTestClean(client);
         }
     }
+
+    @Test
+    public void testIsolatedThreadGroup() throws Exception {
+        AtomicReference<Throwable> exception = new AtomicReference<>();
+
+        CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), 30000, 30000, new RetryOneTime(1));
+        client.getUnhandledErrorListenable().addListener((message, e) -> exception.set(e));
+        client.start();
+
+        ThreadGroup threadGroup1 = new ThreadGroup("testGroup1");
+        Thread thread1 = new Thread(threadGroup1, () -> {
+            try ( final PathChildrenCache cache = new PathChildrenCache(client, "/test1", true) ) {
+                cache.start();
+                Thread.sleep(1000);
+            } catch (Exception e) {
+                exception.set(e);
+            }
+        });
+
+        thread1.start();
+        thread1.join();
+        assertNull(exception.get());

Review Comment:
   nit: I suggest to use  CompletableFuture, not a big deal in any case



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@curator.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org