Duansg opened a new pull request, #7962:
URL: https://github.com/apache/shenyu/pull/7962

   ## What is the problem
   
   `AppAuthServiceImpl#delete` built the `AppAuthData` of a DELETE event 
without a `namespaceId`, and published one event for the whole batch.
   
   Data-changed listeners treat a null namespace as `SYS_DEFAULT_NAMESPACE_ID`:
   - Node-based sync (zookeeper / nacos / etcd / consul / apollo / polaris): 
`AbstractNodeDataChangedListener#onAppAuthChanged` builds the key prefix from 
`default`, so the key `ns-A.<authDataId>.<appKey>` is never deleted.
   - Websocket: `WebsocketDataChangedListener` groups by each item's namespace, 
so the DELETE message only reaches gateways of the default namespace.
   
   **Impact:** after `POST /appAuth/batchDelete` in a non-default namespace 
(e.g. `ns-A`), gateways of `ns-A` keep the deleted appKey/secret, and signed 
requests with it are still accepted. If the default namespace has an app auth 
with the same appKey, that one is wrongly removed instead.
   
   ## What this PR does
   
   - Set `namespaceId` on every `AppAuthData` of the DELETE event. A missing 
value on a legacy row falls back to `SYS_DEFAULT_NAMESPACE_ID`, the same 
default the listeners use, so the delete is never rolled back by an NPE.
   - Group the deleted app auths by namespace and publish one 
`DataChangedEvent(APP_AUTH, DELETE, data, namespaceId)` per namespace. A batch 
spanning several namespaces is no longer routed by its first item only 
(`findFirst()` in the node listeners).
   
   Delivery timing is unchanged: `DataChangedEventDispatcher` still defers 
every event to `afterCommit`. In cluster mode, 
`ClusterDataChangedEventForwarder` already forwards the event's `namespaceId` 
to the master.
   
   ## Tests
   
   `AppAuthServiceTest`:
   - deleting in `ns-A` and in the default namespace keeps the namespace on 
both the event and its data
   - a mixed batch (`ns-A` ×2, `ns-B`, default) publishes exactly 3 events, 
each with only its own app auths
   - a row without a namespace falls back to the default namespace
   - no event is published for empty/null ids, missing records, or 0 / -1 
affected rows
   
   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`.
   


-- 
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