Skip to content

refactor(k8s): remove redundant context path null check - #7523

Merged
Aias00 merged 1 commit into
apache:masterfrom
SwatiKumari250:fix/7510-remove-redundant-null-check
Oct 10, 2026
Merged

Aias00 merged 1 commit into
apache:masterfrom
SwatiKumari250:fix/7510-remove-redundant-null-check

Conversation

@SwatiKumari250

Copy link
Copy Markdown
Contributor

Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

@Aias00 Aias00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Aias00
Aias00 merged commit 4cd79f5 into apache:master Oct 10, 2026
30 checks passed

@wy471x wy471x left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the isBlank guard 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 #7510 plus "the null check is dead because of the isBlank guard above" would make the intent obvious in the changelog.

@dmsolr

dmsolr commented Oct 10, 2026

Copy link
Copy Markdown
Member

closes #7510

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants