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

   Fixes #7590.
   
   `LoadServiceDocEntryImpl.supportSwaggerPluginSet` was a non-volatile 
`static` field. It is written by `loadApiDocument()` on the admin startup 
thread and read from discovery sync callbacks (`loadDocOnUpstreamChanged` → 
`getClusterLastUpdateInstance`) on other threads without synchronization, so 
the reader is not guaranteed to see the update and may keep using the initial 
empty set, which disables API document pulling for every upstream change.
   
   ## Changes
   
   - Make `supportSwaggerPluginSet` a `volatile` field so the write is safely 
published to other threads.
   - Make it an instance field instead of `static`: `LoadServiceDocEntryImpl` 
is a singleton `@Service`, so there is no need to share it across instances.
   - Publish an unmodifiable copy on refresh, and drop the now-unneeded 
`@SuppressWarnings("unchecked")`.
   
   ## Tests
   
   Added `testLoadDocOnUpstreamChangedFromAnotherThread` to 
`LoadServiceDocEntryImplTest`: after `loadApiDocument()` loads the supported 
plugins, it calls `loadDocOnUpstreamChanged` from a different thread, and 
checks that the document is pulled for a supported plugin (`divide`) and not 
for an unsupported one (`dubbo`).
   
   `./mvnw test -pl shenyu-admin -Dtest=LoadServiceDocEntryImplTest` passes (3 
tests), and checkstyle reports no violations.
   
   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.
   - [ ] Your local test passed `./mvnw clean install 
-Dmaven.javadoc.skip=true`.
   
   The full `clean install` was not run locally; the affected module 
(`shenyu-admin` and its dependencies) was built and the changed test class was 
run with checkstyle.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


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