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

   ## Modifications
   
   `RuleServiceImpl#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 rules belonging to another namespace. The sibling delete path 
(`deleteByIdsAndNamespaceId` → `selectByIdsAndNamespaceId`) already scopes by 
namespace before acting; this brings the enable path in line. Companion fix to 
#7524 (the selector-side twin of the same gap).
   
   Ids whose rule is missing or belongs to another namespace are now skipped:
   
   ```java
   RuleDO ruleDO = ruleMapper.selectById(id);
   if (Objects.isNull(ruleDO) || !Objects.equals(ruleDO.getNamespaceId(), 
namespaceId)) {
       // the rule does not belong to the request namespace; skip it
       return;
   }
   ```
   
   ## Verifying this change
   
   - [x] New `RuleServiceTest#enabledByIdsAndNamespaceIdSkipsForeignRules` — 
toggles one own (`ns-a`) and one foreign (`ns-b`) rule for `ns-a` and asserts 
only the own one reaches `updateEnable`. Red on the pre-fix code 
(`NeverWantedButInvoked: updateEnable("rule-foreign", false)`), green after.
   - [x] `./mvnw -pl shenyu-admin -am test -B -Dtest=RuleServiceTest` — 24/24 
green (23 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; 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]

Reply via email to