Sean-Walker0 opened a new pull request, #7817:
URL: https://github.com/apache/shenyu/pull/7817
Fixes #7773
## Modifications
The discovery update path (`POST /discovery/insertOrUpdate` →
`DiscoveryServiceImpl.update`) persisted `serverList`, `props` and `type` to
the database and returned success **without touching the running registry
repository**. The processor cache is keyed by discovery id and
`AbstractDiscoveryProcessor.createDiscovery` returns immediately for a known
id, so the live repository kept serving with the pre-update configuration until
admin restart — `syncData()` could not reconcile it either.
After a successful persisted update, the runtime-relevant fields are
compared against the previously stored row; when `serverList`, `props` or
`type` changed, the cached repository is removed and a fresh one is created
from the updated record:
```java
final boolean configChanged = !Objects.equals(persisted.getServerList(),
updated.getServerList())
|| !Objects.equals(persisted.getProps(), updated.getProps())
|| !Objects.equals(persisted.getDiscoveryType(),
updated.getDiscoveryType());
if (configChanged) {
discoveryProcessor.removeDiscovery(persisted);
discoveryProcessorHolder.chooseProcessor(updated.getDiscoveryType()).createDiscovery(updated);
}
```
Name-only edits leave the live repository untouched (no reconnect churn).
## Verifying this change
- [x] `testUpdateReinitializesRuntimeRepositoryWhenConfigChanges` — a
serverList change must remove the old repository and create a new one, in that
order (`InOrder`). Red on the pre-fix code (the processor was never invoked),
green after.
- [x] `testUpdateSkipsRuntimeRefreshWhenConfigUnchanged` — a name-only edit
must not touch the processor (guards against needless repository churn).
- [x] `./mvnw -pl shenyu-admin -am test -B -Dtest=DiscoveryServiceImplTest`
— 27/27 green (25 pre-existing cases unchanged), module checkstyle clean.
## Notes
- Behavior change: runtime-relevant discovery edits now take effect
immediately (remove + recreate of the repository) instead of requiring an admin
restart; identical-config updates behave exactly as before.
- The remove+create cycle drops and re-registers the listeners attached to
the old repository — the same lifecycle `delete()` already uses, so watch
clients reconnect through the existing path.
- Orthogonality: no open PR modifies `DiscoveryServiceImpl` (verified
against the file lists of all 120 open PRs; the earlier #7514/#7469-lineage PRs
are all merged).
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-admin` targeted test class +
checkstyle green; full-module suite left to CI as with the other admin PRs).
--
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]