Sean-Walker0 opened a new pull request, #7524:
URL: https://github.com/apache/shenyu/pull/7524
## Modifications
`SelectorServiceImpl#enabledByIdsAndNamespaceId` accepted a `namespaceId`
parameter but **never used it**: each id was loaded with the unscoped
`selectById` and toggled directly, so a request for one namespace could enable
or disable selectors belonging to another namespace (cross-tenant state
tampering through the batch enable API). The sibling delete path
(`deleteByIdsAndNamespaceId`) already scopes by namespace before acting; this
brings the enable path in line.
Ids whose selector is missing or belongs to another namespace are now
skipped:
```java
SelectorDO selectorDO = selectorMapper.selectById(id);
if (Objects.isNull(selectorDO) ||
!Objects.equals(selectorDO.getNamespaceId(), namespaceId)) {
// the selector does not belong to the request namespace; skip it
return;
}
```
(This started as the follow-up direction noted in the review of #7514 — the
same namespace-consistency family.)
## Verifying this change
- [x] New
`SelectorServiceTest#enabledByIdsAndNamespaceIdSkipsForeignSelectors` — toggles
one own (`ns-a`) and one foreign (`ns-b`) selector for `ns-a` and asserts only
the own one reaches `updateEnable`. Red on the pre-fix code
(`NeverWantedButInvoked: updateEnable("sel-foreign", false)`), green after.
- [x] `./mvnw -pl shenyu-admin -am test -B -Dtest=SelectorServiceTest` —
16/16 green (15 pre-existing cases unchanged), module checkstyle clean.
## Notes
- Behavior change: ids outside the request namespace are skipped instead of
toggled — which is what the method's name and signature promise.
- Also guards the previously unhandled `selectById == null` case in the same
loop (the old code would have thrown an NPE while serializing the before-state).
- Orthogonality: #7001 (open) touches other methods of this class for the
mapper-signature migration (`selectByIdSet`/tests); its diff was compared and
does not touch `enabledByIdsAndNamespaceId`.
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]