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

   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`.
   
   ## What this PR does
   
   Fixes #6838.
   
   `ApolloDataService` registered its change listener with **bare** data IDs 
(`"plugin"`, `"selector"`, `"rule"`, ...) as `interestedKeyPrefixes`, but 
Apollo publishes namespace-prefixed keys (`{namespaceId}.plugin.{pluginName}` 
per `AbstractNodeDataSyncService`). Apollo's 
`AbstractConfig.isConfigChangeListenerInterested` therefore never matched, and 
every incremental change event was silently dropped after startup — the gateway 
only picked up config changes on full restart.
   
   ### Changes:
   
   1. `ApolloPathConstants.pathKeySet(String namespaceId)` 
(ApolloPathConstants.java:99) — new overload that returns namespace-prefixed 
path keys (`{namespaceId}.plugin`, `{namespaceId}.rule`, ...), matching the key 
format Apollo actually publishes.
   2. `ApolloDataService.apolloWatchPrefixes` (ApolloDataService.java:88) — 
registers the change listener with the namespace-prefixed interested key set so 
Apollo's real prefix filtering 
(`AbstractConfig.isConfigChangeListenerInterested`) lets the events through.
   3. `ApolloDataService` change handler (ApolloDataService.java:104-146) — 
replaced `changeKey.indexOf(DATA_ID) == 0` with 
`changeKey.startsWith(namespacePrefix + DATA_ID)` for 
plugin/selector/rule/auth/meta/proxy-selector/discovery, so namespace-prefixed 
keys are routed to the correct cache handlers.
   4. `AbstractNodeDataSyncService.unCachePluginData` 
(AbstractNodeDataSyncService.java:219) — parses the plugin name from the 
namespace-prefixed key and validates the key before indexing (same pattern as 
the #6955 eviction fix), preventing index-out-of-bounds on malformed keys.
   
   ### Test Cases:
   
   1. `ApolloDataServiceIntegrationTest` (new) — flows through apollo-client's 
real listener filtering via `DefaultConfig.onRepositoryChange`; verifies 
incremental `MODIFIED` and `DELETED` events reach the plugin subscriber and 
that the unsubscribed plugin name is parsed from the namespace-prefixed key.
   2. `ApolloDataServiceTest` — migrated all keys to the namespace-prefixed 
format; added deleted-event tests for plugin/rule/proxy-selector, a list-key 
skip test, and a wrong-namespace prefix ignore test.
   3. `AbstractNodeDataSyncServiceTest` — covers the new plugin key parsing and 
the malformed-key guard.
   
   ## Verification
   
   - `shenyu-sync-data-apollo` module tests passed with `-am` dependencies 
(`shenyu-common`, `shenyu-sync-data-api`): 20 tests, 0 failures, including the 
2 new integration tests.
   - Checkstyle passed on all touched modules (`shenyu-common`, 
`shenyu-sync-data-api`, `shenyu-sync-data-apollo`).
   - License header on the new test file verified against the existing module 
header.
   
   close #6838
   


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