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

   <!-- Describe your PR here; e.g. Fixes #issueNo -->
   Found by code audit (no existing issue — happy to file one if maintainers 
prefer).
   
   `PluginHandleServiceImpl#findById` passes 
`pluginHandleMapper.selectById(id)` straight into 
`buildPluginHandleVO(PluginHandleDO)`, which dereferences 
`pluginHandleDO.getDataType()` — for a deleted or nonexistent handle id the 
mapper returns null and the admin REST endpoint 
(`PluginHandleController#findById`, raw `@PathVariable`) answers 500 with a 
`NullPointerException` instead of an empty result. Sibling services guard the 
identical pattern (`DetailServiceImpl#findById`, `FieldServiceImpl#findById` 
both null-check the mapper result), and `PluginHandleVO.buildPluginHandleVO` 
itself is already null-safe via `Optional`.
   
   <!--
   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-admin -am and ./mvnw 
checkstyle:check -pl shenyu-admin` (module-scoped; full build left to CI).
   
   ### Modifications
   
   - Add `Objects.nonNull(pluginHandleDO) &&` to the dict-options condition in 
`buildPluginHandleVO(PluginHandleDO)`; an unknown id now flows to the already 
null-safe VO builder and resolves to null.
   
   ### Verifying this change
   
   - New `PluginHandleServiceImplTest#findByIdShouldNotThrowForUnknownId` mocks 
the mapper to return null and asserts `findById` returns null instead of 
throwing. It fails on current master with `NullPointerException: Cannot invoke 
"PluginHandleDO.getDataType()" because "pluginHandleDO" is null` and passes 
with this change.
   - Full `shenyu-admin` module suite green (503 test classes); checkstyle 
green.
   
   ### Notes
   
   - Behavior change: `GET /pluginHandle/{id}` for an unknown id now returns an 
empty-data success payload instead of 500.
   - Orthogonal to open PRs: no open PR touches `PluginHandleServiceImpl`.


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