Repository navigation
refactor(k8s): remove redundant context path null check - #7523
Conversation
Aias00
left a comment
There was a problem hiding this comment.
Summary
Removes a redundant if (Objects.isNull(contextPath)) continue; in
ContextPathParser.parseIngressRule.
Verification
The removal is safe: line 119 already does if (StringUtils.isBlank(annotations.get(PLUGIN_CONTEXT_PATH_PATH))) ... continue;
before line 125 assigns contextPath, so by the time contextPath is read it is guaranteed
non-null/non-blank. The deleted block could never execute. Objects remains used at lines 110/116/164,
so no orphaned import is introduced.
CI note
No checks were reported on the fix/7510-remove-redundant-null-check branch. The change is a
3-line dead-code removal that I verified against the surrounding code, but please rebase to trigger
the build and confirm checkstyle/compile.
Conclusion
Approved (trivially safe). Rebase to get a green run.
wy471x
left a comment
There was a problem hiding this comment.
LGTM — the removed branch really is unreachable, so this is a safe cleanup.
parseIngressRule already exits the loop a few lines above with StringUtils.isBlank(annotations.get(PLUGIN_CONTEXT_PATH_PATH)) -> LOG.info(...) + continue, and resolveContextPathAnnotations can only ever put non-null values into the map (it reads both the ingress and the referenced-service annotations through MapUtils.emptyIfNull), so Objects.isNull(contextPath) could not be true at the point where it was checked. Keeping the earlier guard is also the better of the two, because it names the skipped path in the log line.
Verified on the branch (JDK 21): ./mvnw -o -pl shenyu-kubernetes-controller -am test -Dtest='ContextPathParserTest,ContextPathParserAnnotationsTest' -> 7/7 and 4/4 green, checkstyle clean. No behavior change, so no test needed for the deletion itself.
Minor notes (non-blocking):
String contextPath = annotations.get(IngressConstants.PLUGIN_CONTEXT_PATH_PATH);now repeats the lookup that theisBlankguard immediately above already performed; passing the already-read value would be marginally tidier, but it is fine as is.- The PR description is still the raw template — a one-line
Fixes #7510plus "the null check is dead because of the isBlank guard above" would make the intent obvious in the changelog.
|
closes #7510 |
Make sure that:
./mvnw clean install -Dmaven.javadoc.skip=true.