Repository navigation
Conversation
…rPathChildrenCache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1318.
forPathChildrenCache(rootPath, client, listener)is documented to bridge only events for children ofrootPath, butPathChildrenCacheListenerWrapperonly skippedrootPathitself. SinceCuratorCachewatches the whole tree, aPathChildrenCacheListenerbehind the bridge receivedCHILD_ADDED,CHILD_UPDATEDandCHILD_REMOVEDfor grandchildren and deeper nodes. With the same operations,PathChildrenCachereportedCHILD_ADDED /old/a, CHILD_REMOVED /old/a, while the bridge also reportedCHILD_ADDED /new/a/x, CHILD_UPDATED /new/a/x, CHILD_REMOVED /new/a/x.ServiceCacheImplis built on the same bridge. With aPERMANENTinstance, a node created under the instance node was deserialized as aServiceInstance(the listener container logged aJsonParseException), and deleting it firedcacheChanged()with no instance change.The wrapper now forwards an event only when the parent of the event path is
rootPath. The check forrootPathitself stays, so a cache on/still does not report the root.testPathChildrenCacheIgnoresGrandchildreninTestCuratorCacheWrapperscreates, updates and deletes/test/one/twounder/test/oneand expects only the two events for/test/one. Without the change it fails withexpected: <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/afrom the bridge, and theServiceCacheneither logs an error nor callscacheChanged().I ran
TestCuratorCacheWrappers, theorg.apache.curator.framework.recipes.cachetests in curator-recipes (77 run, 0 failures, 1 skipped) and the curator-x-discovery tests (45 run, 0 failures) on JDK 17, plusspotless:checkand the hawkeye header check.TestCuratorCacheConsistency.testConsistencyAfterSimulationfailed 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, whereCuratorCachefalls back toTreeCachebut uses the same wrapper.