Parameters becomes a thin facade over the shared string-backed implementation#492
Open
milyin wants to merge 1 commit into
Open
Parameters becomes a thin facade over the shared string-backed implementation#492milyin wants to merge 1 commit into
milyin wants to merge 1 commit into
Conversation
…entation The per-SDK map-backed parser duplicated zenoh-kotlin's and diverged from Rust: it percent-decoded values, rejected duplicated keys (throwing on attacker-controlled selector parameters in the queryable upcall), and normalized eagerly. io.zenoh.query.Parameters now delegates every operation to the shared io.zenoh.jni.query.Parameters (zenoh-flat-jni), a pure-Kotlin string-backed mirror of Rust's zenoh-protocol parameters.rs — construction is infallible on any input with zero JNI crossings. Behavior changes, all aligning with Rust: no percent-decoding; from(String) never throws; duplicated keys accepted with first-match-wins get (last wins in toMap, as Rust's HashMap conversion); trailing ';'/'='/'|' trimmed at construction; toString round-trips the stored string; equality is string equality. New ParametersCorrespondenceTest validates the shared implementation against the native parameters_get/insert/is_well_formed oracle (zenoh-flat#4) over edge shapes and 500 randomized inputs — it caught the trailing-separator trim rule. remove is correspondence-exempt: upstream zenoh's parameters::remove has an iterator-consumption bug (find advances past entries preceding the first match before filter runs, dropping them; removing an absent key erases everything); the shared implementation follows the documented 'preserving the insertion order' contract instead, and nativeRemoveBugCanary pins the buggy native behavior so the exemption is removed when upstream fixes it. Also folds in the RX hardening that motivated the unification: queryCallbackOf frees the owned native leaves and finalizes the query if decomposition ever throws, and QueryParametersTest sends a=1;a=2;bad=%zz through the raw bindings end to end. CI pins bump to zenoh-flat#4 and zenoh-flat-jni#9. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
6 tasks
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.
io.zenoh.query.Parametersnow delegates every operation to the sharedio.zenoh.jni.query.Parameters(ZettaScaleLabs/zenoh-flat-jni#9) — a pure-Kotlin, string-backed mirror of Rust'szenoh-protocol/core/parameters.rs. Companion of eclipse-zenoh/zenoh-kotlin#670: the duplicated per-SDK parsers are gone, construction is infallible on any remote (attacker-controlled) input, and there are zero JNI crossings on the production path.Behavior changes (all aligning with Rust)
Parameters,Selector).from(String)never throws; duplicated keys accepted —getreturns the FIRST occurrence,toMapkeeps the last (Rust'sHashMapconversion).;/=/|characters are trimmed at construction (RustParameters::from'strim_end_matches).toString()round-trips the stored string verbatim;insert/removenormalize. Equality is string equality.Correspondence testing (the pure-JVM rule)
New
ParametersCorrespondenceTestdrives the shared implementation and the native oracle (parametersGet/Insert/IsWellFormedfrom ZettaScaleLabs/zenoh-flat#4) over edge shapes + 500 randomized separator-dense inputs. It caught a real rule on the first run: the trailing-separator trim above.removeis correspondence-exempt: upstream zenoh'sparameters::removehas an iterator-consumption bug —findadvances past every entry up to and including the first match beforefilterbuilds the result, so entries PRECEDING the match are dropped (remove("b=2;a=1;c=3","a") → "c=3"), and removing an absent key erases the whole string (remove("x=1;y=2","missing") → ""). The shared implementation follows the documented “preserving the insertion order” contract instead;nativeRemoveBugCanarypins the buggy native behavior so the exemption is deleted the moment upstream fixes it. Worth reporting to eclipse-zenoh/zenoh.Folded RX hardening
queryCallbackOfgains defense-in-depth (frees the owned payload/attachment leaves and finalizes the query if decomposition ever throws), andQueryParametersTestsendsa=1;a=2;bad=%zzthrough the raw bindings end to end — completing the malformed-selector-parameters hardening for zenoh-java.Testing
./gradlew jvmTest: 120 tests, 0 failed (standalone run). Merge order: zenoh-flat#4 → zenoh-flat-jni#9 → this (CI pins bumped).🤖 Generated with Claude Code