Sean-Walker0 opened a new pull request, #7514:
URL: https://github.com/apache/shenyu/pull/7514
Fixes #7467
## Modifications
`ProxySelectorServiceImpl#create` loaded the nested discovery with
`discoveryMapper.selectById(id)` — which filters by id only — and reduced a
missing row to `fillDiscovery = false`. Two holes followed: a proxy selector
could **bind to a discovery belonging to another namespace** (the mapper query
is not namespace-scoped), and an **unknown discovery id was silently ignored**,
leaving a selector with no discovery wiring instead of an error.
The loaded discovery is now validated before use, using the same `Assert`
style as the rest of this class:
```java
Assert.notNull(discoveryDO, "Discovery does not exist: " + ...);
Assert.isTrue(Objects.equals(discoveryDO.getNamespaceId(),
proxySelectorAddDTO.getNamespaceId()),
"Discovery does not belong to namespace: " + ...);
```
Both failures reject the create with `ValidFailException` inside the
`@Transactional` boundary, so no partial row survives.
## Verifying this change
- [x] New `ProxySelectorServiceImplTest` (first test class for this
service): `createRejectsDiscoveryFromAnotherNamespace` and
`createRejectsUnknownDiscoveryId` — both red on the pre-fix code (the create
succeeded/continued instead of throwing), green after;
`createAcceptsDiscoveryFromSameNamespace` guards the success path end-to-end
(handler + rel inserted, processor invoked).
- [x] `./mvnw -pl shenyu-admin -am test -B
-Dtest=ProxySelectorServiceImplTest` — 3/3 green, module checkstyle clean
(full-module suite is exercised in CI).
## Notes
- Behavior change: a nonexistent discovery id now fails the request instead
of silently creating an unwired selector; a cross-namespace id now fails
instead of binding — both are the isolation guarantees this API's `namespaceId`
parameter implies.
- Orthogonality: #7497 (open) modifies the import/`DataChangedEvent` region
of the same file and #7387 (ours, open) the `listAllData` method — neither
touches the `create` discovery-loading branch; the changed hunks do not overlap.
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]