Skip to content

[Refactor] Clean up redundant null guard for contextPath(ContextPathParser) #7510

Closed

Description

@poliglots

Description

Description

During the review of pull request #7031, a redundant null branch was identified in the code.

There is an existing StringUtils.isBlank(contextPath) guard that executes beforehand, which already filters out null, empty, and whitespace-only values. Because contextPath is read from the same local annotations map, the subsequent if (contextPath == null) branch is unreachable code.

Proposed Solution

Remove the duplicate null branch to clean up the codebase while ensuring the local variable passed to the helper utilities remains intact.

Additional Context

Polishing task identified during the merge of #7031.

Task List

No response

Activity

  1. poliglots commented on Oct 8, 2026

    @poliglots
    ContributorAuthor

    Goal is - Consider removing this duplicate guard while retaining the local variable passed to the helpers.

    in the shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/ContextPathParser.java...

                        ConditionData pathCondition = createPathCondition(pathPath, operator);
                        List<ConditionData> conditionList = new ArrayList<>(2);
                        String contextPath = annotations.get(IngressConstants.PLUGIN_CONTEXT_PATH_PATH);
                        if (Objects.isNull(contextPath)) {
    

    look at the line no. 126 in #7031 (comment), this needs to be removed

  2. github-actions commented on Oct 8, 2026

    @github-actions
    Contributor

    👋 Hello @Aias00

    A new issue has been opened by @poliglots:

    Please review when you have time. Thank you! 🙏

  3. Aias00 commented on Oct 23, 2026

    @Aias00
    Contributor

    The requested cleanup is already on current master 34f2ed036: merged #7523 (4cd79f566) removed the redundant contextPath == null branch. parseIngressRule retains the preceding StringUtils.isBlank(...) guard and passes the resolved local context path into the helper methods.

    Current ContextPathParser

    Closing as completed; this is the exact polishing change requested here, not a replacement of the broader context-path behavior.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions