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

   <!-- Describe your PR here; e.g. Fixes #issueNo -->
   Fixes #6787
   
   `ShenyuClientURIExecutorSubscriber` kept its registered URI list in a 
**static** `CopyOnWriteArrayList` that was only ever added to — never removed, 
never deduplicated — and shared by every subscriber instance in the JVM. 
Consequences:
   
   - after a client context restart in the same JVM (Spring DevTools, 
integration tests, embedded multi-app setups) the heartbeat scheduler keeps 
beating **stale URIs from the previous context** every 10 seconds;
   - each re-registration of the same URI appends a **duplicate** entry (double 
heartbeats, an extra offline hook);
   - different client types each build their own subscriber with their own 
repository, but heartbeat the **same shared list**, so one repository sends 
heartbeats for another type's URIs.
   
   <!--
   Thank you for proposing a pull request. This template will guide you through 
the essential steps necessary for a pull request.
   -->
   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 test -pl 
shenyu-client/shenyu-client-core -am` and `./mvnw checkstyle:check -pl 
shenyu-client/shenyu-client-core` (module-scoped; full build left to CI).
   
   ### Modifications
   
   - `URIS` static field → instance field `uris`: each subscriber instance 
tracks only the URIs registered through it, so instances from different client 
contexts no longer interfere.
   - New `addUriIfAbsent`: skip adding a URI whose 
`namespaceId`/`contextPath`/`host`/`port` are already registered (field-based, 
not identity-based, so a rebuilt DTO does not duplicate).
   - `persistURI` remains unconditional on every registration event — dedup 
affects only the heartbeat list.
   
   ### Verifying this change
   
   - New unit tests in `ShenyuClientURIExecutorSubscriberTest`:
     - re-registering an equal URI keeps the list at size 1 while `persistURI` 
is still called for both events;
     - URIs on different ports both stay registered;
     - URIs registered through one subscriber instance do **not** appear in 
another instance's list (the previous static code fails all three).
   - `shenyu-client-core`: 90/90 tests passed; checkstyle passed.
   
   ### Notes
   
   - The open PRs #7082 (idempotent publisher start) and #7144 (offline failure 
propagation) touch neighbouring code in the same class but do **not** change 
the `URIS` field; this PR only modifies the field, the heartbeat lambda 
reference and the add call, so the changes are orthogonal (a small rebase may 
be needed depending on merge order).
   


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