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

   <!-- Describe your PR here; e.g. Fixes #issueNo -->
   Found by code audit (no existing issue — happy to file one if maintainers 
prefer).
   
   `KubernetesInstanceRegisterRepository#init` reads 
`properties.getProperty("namespaces").split(",")` with no default — when the 
registry configuration omits the `namespaces` property, `getProperty` returns 
null and startup crashes with `NullPointerException`. Every sibling repository 
defaults its optional props (e.g. `ZookeeperInstanceRegisterRepository`, 
`NacosInstanceRegisterRepository` use `getProperty(key, default)`), and 
`KubernetesClient#matchNamespaces` already treats an empty namespace list as 
*match all namespaces*, which is therefore the intended default here.
   
   <!--
   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-registry/shenyu-registry-kubernetes -am and ./mvnw checkstyle:check -pl 
shenyu-registry/shenyu-registry-kubernetes` (module-scoped; full build left to 
CI).
   
   ### Modifications
   
   - Default the property to an empty string and translate empty to an empty 
list (`Collections.emptyList()`), so an omitted `namespaces` means *match all* 
exactly as `matchNamespaces` defines. Configured values behave exactly as 
before.
   
   ### Verifying this change
   
   - New `initShouldNotThrowWhenNamespacesPropertyIsAbsent` builds a 
`RegisterConfig` without the property and asserts `init` completes with an 
empty namespace list. It fails on current master with `NullPointerException: 
Cannot invoke "String.split(String)" because the return value of 
"getProperty(String)" is null` and passes with this change.
   - Full `shenyu-registry-kubernetes` module suite green; checkstyle green.
   
   ### Notes
   
   - Behavior change: omitting `namespaces` now selects all namespaces instead 
of crashing startup.
   - Orthogonal to open PRs: no open PR touches `shenyu-registry-kubernetes`.


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