Sean-Walker0 opened a new pull request, #7570:
URL: https://github.com/apache/shenyu/pull/7570

   Fixes #7559
   
   ## Modifications
   
   The default `getPluginArgumentId` / `getSelectorArgumentId` / 
`getRuleArgumentId` all returned `0L`, while the argument maps are **static** 
and every call removes its entry in a `finally` block. Overlapping callbacks of 
the same data type therefore overwrote the same map entry, and the first 
callback's cleanup removed the other call's live argument before the guest 
could read it back through `get_args`.
   
   The defaults now come from a shared `AtomicLong`, making them globally 
unique across types, instances and calls:
   
   ```java
   private static final AtomicLong NEXT_ARGUMENT_ID = new AtomicLong();
   
   protected Long getPluginArgumentId(final PluginData pluginData) {
       return NEXT_ARGUMENT_ID.incrementAndGet();
   }
   ```
   
   The uniqueness contract is documented on the field; subclasses overriding 
the generators own that contract explicitly (the id is only used as an opaque 
handle between the host and one guest invocation).
   
   ## Verifying this change
   
   - [x] New 
`AbstractWasmPluginDataHandlerTest#defaultArgumentIdsAreUniqueAcrossTypesAndCalls`
 — a handler subclass keeping the default generators (loading a copied Go 
fixture so the resource lookup matches the class name) asserts four consecutive 
ids across the three types are distinct. Red on the pre-fix code (`expected: 
<4> but was: <1>` — all defaults returned `0L`), green after.
   - [x] `./mvnw -pl shenyu-plugin/shenyu-plugin-wasm-base -am test -B` — 23/23 
module tests green (12 pre-existing cases unchanged), checkstyle clean.
   
   ## Notes
   
   - Behavior change: default ids are now non-zero and unique — the id is an 
opaque handle, so no well-formed guest is affected; subclasses that override 
the generators are unchanged.
   - The existing test superclass already worked around the collision with its 
own `AtomicLong`, which corroborates the reported defect.
   - Orthogonality: the open WASM PRs (#7567/#7568/#7569) modify 
`WasmLoader.java` and other classes; none of them touches 
`AbstractWasmPluginDataHandler` (verified by file-list + patch inspection).
   
   Make sure that:
   
   - [x] You have read the [contribution 
guidelines](https://shenyu.apache.org/community/contributor-guide).
   - [x] You submit test cases (unit or integration tests) that back your 
changes.
   - [x] Your local test passed `./mvnw clean install 
-Dmaven.javadoc.skip=true` (module-scoped: 
`shenyu-plugin/shenyu-plugin-wasm-base` with `-am`, tests + checkstyle green).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to