Skip to content

Commit

Permalink
Fix overlapping path logic and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
dlmarion committed Jan 16, 2025
1 parent 167739e commit 672e3a0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,12 @@ public void addZooCacheWatcher(ZooCacheWatcher watcher) {

// Visible for testing
protected void setupWatchers(List<String> 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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,22 @@ public void setUp() {
public void testOverlappingPaths() {
assertThrows(IllegalArgumentException.class,
() -> new ZooCache(zk, List.of(root, root + "/localhost:9995")));

List<String> 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
Expand Down

0 comments on commit 672e3a0

Please sign in to comment.