Skip to content

GH-1318: Bridge only direct children in CuratorCacheListener#forPathChildrenCache - #1319

Open
PDGGK wants to merge 1 commit into
apache:masterfrom
PDGGK:GH-1318
Open

PDGGK wants to merge 1 commit into
apache:masterfrom
PDGGK:GH-1318

Conversation

@PDGGK

@PDGGK PDGGK commented Nov 10, 2026

Copy link
Copy Markdown

Fixes #1318.

forPathChildrenCache(rootPath, client, listener) is documented to bridge only events for children of rootPath, but PathChildrenCacheListenerWrapper only skipped rootPath itself. Since CuratorCache watches the whole tree, a PathChildrenCacheListener behind the bridge received CHILD_ADDED, CHILD_UPDATED and CHILD_REMOVED for grandchildren and deeper nodes. With the same operations, PathChildrenCache reported CHILD_ADDED /old/a, CHILD_REMOVED /old/a, while the bridge also reported CHILD_ADDED /new/a/x, CHILD_UPDATED /new/a/x, CHILD_REMOVED /new/a/x.

ServiceCacheImpl is built on the same bridge. With a PERMANENT instance, a node created under the instance node was deserialized as a ServiceInstance (the listener container logged a JsonParseException), and deleting it fired cacheChanged() with no instance change.

The wrapper now forwards an event only when the parent of the event path is rootPath. The check for rootPath itself stays, so a cache on / still does not report the root.

testPathChildrenCacheIgnoresGrandchildren in TestCuratorCacheWrappers creates, updates and deletes /test/one/two under /test/one and expects only the two events for /test/one. Without the change it fails with expected: <CHILD_REMOVED> but was: <CHILD_ADDED>, because the second event is the one for /test/one/two.

With the change, the same side-by-side program run against jars built from this branch gets INITIALIZED, CHILD_ADDED /new/a, CHILD_REMOVED /new/a from the bridge, and the ServiceCache neither logs an error nor calls cacheChanged().

I ran TestCuratorCacheWrappers, the org.apache.curator.framework.recipes.cache tests in curator-recipes (77 run, 0 failures, 1 skipped) and the curator-x-discovery tests (45 run, 0 failures) on JDK 17, plus spotless:check and the hawkeye header check. TestCuratorCacheConsistency.testConsistencyAfterSimulation failed once with "A client's error handler was called" and passed on the surefire rerun; it does not use the bridge. I did not run the JDK 8, 11 and 21 legs or the ZooKeeper 3.5 to 3.8 compatibility modules, where CuratorCache falls back to TreeCache but uses the same wrapper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CuratorCacheListener.forPathChildrenCache() forwards events for grandchildren as child events

1 participant