Session.undeclare: detach the key-expr handle even when undeclare fails#491
Merged
Merged
Conversation
The generated wrapper consumes the handle even when the native undeclare errors (the Rust side takes it by value). Clearing keyExpr.handle only after a successful call left a dead handle attached on failure: every later operation selected the closed handle and failed instead of degrading to the string form. Detach in a finally; regression-tested by undeclaring through the wrong session. Found while porting zenoh-kotlin (eclipse-zenoh/zenoh-kotlin#668), which had inherited the same pattern. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
The generated
undeclareKeyexprwrapper consumes the key-expr handle even when the native undeclare fails (the Rust side takes it by value —finally { keyExpr.markConsumed() }in the generated code).Session.undeclareclearedkeyExpr.handleonly after a successful call, so on failure a dead (consumed) handle stayed attached: every later operation on thatKeyExprselected the closed handle and failed with "Operation on a closed native handle" instead of degrading to the string form, as the ownership model promises.Detach the handle in a
finallyso theKeyExprdegrades to string-backed either way. Regression test: declaring on one session and undeclaring through another makes the native undeclare fail; the test asserts the handle is detached and string-backed operations (algebra,put) keep working.Found by review on the zenoh-kotlin port (eclipse-zenoh/zenoh-kotlin#668), which had inherited the same pattern and is fixed there identically.
KeyExprHandleTest: 4/4 green.🤖 Generated with Claude Code