Repository navigation
GH-1314: Fix PersistentWatcher with CuratorFramework implementations that are not CuratorFrameworkBase - #1315
Merged
Merged
Conversation
…tions that are not CuratorFrameworkBase Use the underlying client only for CuratorFrameworkBase instances (namespaced facades, apache#1259) and fall back to the public getCuratorListenable() otherwise, so that PersistentWatcher and CuratorCache work with any CuratorFramework implementation again, e.g. a decorator of the public interface.
kezhuw
approved these changes
Oct 26, 2026
kezhuw
left a comment
Member
There was a problem hiding this comment.
LGTM.
Generally speaking, all implementations should come from curator as CuratorFramework itself is constructed from cutator and some of its api (say, usingNamespace) are depended by internal codes. Before #517, there are plenty casts to CuratorFrameworkImpl. That is why I added the "MUST BE" statement.
I guess forwarding could be the only way to meet curator.
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.
Since #1262,
PersistentWatchercasts the client toCuratorFrameworkBaseto reach the underlying client, becauseNamespaceFacadedoes not supportgetCuratorListenable(). As a result,PersistentWatcherandCuratorCachefail withClassCastExceptionfor any otherCuratorFrameworkimplementation, for example a decorator of the public interface. This worked in 5.8.0.This change uses the underlying client only for
CuratorFrameworkBaseinstances, so namespaced facades keep working (#1259). For any other implementation it falls back to the publicgetCuratorListenable(). Bothstart()andclose()are covered; the cast inclose()was added by #1293.Two tests are added to
TestPersistentWatcher. They use ajava.lang.reflect.Proxy-based delegating client and cover:Closednotification;Both tests fail on master with
ClassCastExceptionand pass with the fix.TestPersistentWatcher,TestCuratorCache*andspotless:checkpass locally on JDK 21.Fixes #1314.