From 672e3a06bdedcc31111c0a6da33cbd2d30750974 Mon Sep 17 00:00:00 2001 From: Dave Marion Date: Thu, 16 Jan 2025 13:56:50 +0000 Subject: [PATCH] Fix overlapping path logic and add test --- .../accumulo/core/fate/zookeeper/ZooCache.java | 5 +++-- .../core/fate/zookeeper/ZooCacheTest.java | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooCache.java b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooCache.java index fc64fc5e31b..77fe858206c 100644 --- a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooCache.java +++ b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooCache.java @@ -234,11 +234,12 @@ public void addZooCacheWatcher(ZooCacheWatcher watcher) { // Visible for testing protected void setupWatchers(List pathsToWatch) { + for (String left : pathsToWatch) { for (String right : pathsToWatch) { - if (left.equals(right) && left.contains(right)) { + if (!left.equals(right) && left.contains(right)) { throw new IllegalArgumentException( - "Overlapping paths found in paths to watch: " + pathsToWatch); + "Overlapping paths found in paths to watch. left: " + left + ", right: " + right); } } } diff --git a/core/src/test/java/org/apache/accumulo/core/fate/zookeeper/ZooCacheTest.java b/core/src/test/java/org/apache/accumulo/core/fate/zookeeper/ZooCacheTest.java index ac0bea3fc64..034b298f1c1 100644 --- a/core/src/test/java/org/apache/accumulo/core/fate/zookeeper/ZooCacheTest.java +++ b/core/src/test/java/org/apache/accumulo/core/fate/zookeeper/ZooCacheTest.java @@ -91,6 +91,22 @@ public void setUp() { public void testOverlappingPaths() { assertThrows(IllegalArgumentException.class, () -> new ZooCache(zk, List.of(root, root + "/localhost:9995"))); + + List goodPaths = List.of("/accumulo/8247eee6-a176-4e19-baf7-e3da965fe050/compactors", + "/accumulo/8247eee6-a176-4e19-baf7-e3da965fe050/dead/tservers", + "/accumulo/8247eee6-a176-4e19-baf7-e3da965fe050/gc/lock", + "/accumulo/8247eee6-a176-4e19-baf7-e3da965fe050/managers/lock", + "/accumulo/8247eee6-a176-4e19-baf7-e3da965fe050/namespaces", + "/accumulo/8247eee6-a176-4e19-baf7-e3da965fe050/recovery", + "/accumulo/8247eee6-a176-4e19-baf7-e3da965fe050/root_tablet", + "/accumulo/8247eee6-a176-4e19-baf7-e3da965fe050/sservers", + "/accumulo/8247eee6-a176-4e19-baf7-e3da965fe050/tables", + "/accumulo/8247eee6-a176-4e19-baf7-e3da965fe050/tservers", + "/accumulo/8247eee6-a176-4e19-baf7-e3da965fe050/users", + "/accumulo/8247eee6-a176-4e19-baf7-e3da965fe050/mini", + "/accumulo/8247eee6-a176-4e19-baf7-e3da965fe050/monitor/lock"); + new ZooCache(zk, goodPaths); + } @Test