Skip to content

fix: guard ingress upstream protocol index (#6864) - #6966

Open
juicewcode wants to merge 10 commits into
apache:masterfrom
juicewcode:fix/6864-k8s-ingress-protocol-bounds
Open

juicewcode wants to merge 10 commits into
apache:masterfrom
juicewcode:fix/6864-k8s-ingress-protocol-bounds

Conversation

@juicewcode

Copy link
Copy Markdown
Contributor

Fixes #6864

Summary

  • For a Divide or Dubbo ingress whose upstreams-protocol annotation contains fewer values than endpoint addresses, the
    ingress parsers indexed the protocol array once per endpoint. When the endpoint count exceeded the protocol count,
    protocol[i++] or protocols[i++] threw an ArrayIndexOutOfBoundsException during reconcile, blocking route configuration.
    This PR adds protocol array bounds checks: Divide upstreams fall back to http://, while Dubbo upstreams fall back to
    dubbo:// when configured protocols are exhausted. It also removes the duplicate index increment in the Dubbo protocol
    expression.

  • Added regression cases to DivideIngressReconcilerTest and DubboReconcilerTest —
    testReconcileWithFewerProtocolsThanEndpoints verifies that two endpoint addresses with only one configured protocol
    reconcile successfully, preserving the configured protocol for the first upstream and applying the appropriate default
    protocol to the remaining upstream. Existing testReconcile methods remain unchanged.

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.

juicewcode and others added 3 commits August 22, 2026 01:47
  Prevent Divide and Dubbo ingress parsers from throwing
  ArrayIndexOutOfBoundsException when fewer protocols than endpoints
  are configured. Fall back to http:// and dubbo:// respectively.
Aias00
Aias00 previously approved these changes Aug 26, 2026

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

Reviewed the changes and did not find blocking issues.

  Clear singleton ingress-related caches before each test to prevent
  selectors from previous test cases causing duplicate deletion invocations.
@juicewcode

Copy link
Copy Markdown
Contributor Author

After merging the main branch, the ingress deletion test intermittently failed because the process-wide singleton caches retained data from previous test cases. This caused multiple selectors to be deleted and triggered Mockito's TooManyActualInvocations error.
This change clears IngressCache, IngressSelectorCache, and ServiceIngressCache before each test, ensuring test isolation and preventing stale selector data from affecting verification.ocations.

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

REQUEST_CHANGES (PMC Aias00): this PR has merge conflicts (CONFLICTING) and cannot be merged. Please rebase onto the latest master and resolve the conflicts, then request a re-review.

…s-protocol-bounds

# Conflicts:
#	shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/DivideIngressParser.java
#	shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/DubboIngressParser.java
#	shenyu-kubernetes-controller/src/test/java/org/apache/shenyu/k8s/DubboReconcilerTest.java
@juicewcode

Copy link
Copy Markdown
Contributor Author

REQUEST_CHANGES (PMC Aias00): this PR has merge conflicts (CONFLICTING) and cannot be merged. Please rebase onto the latest master and resolve the conflicts, then request a re-review.

Conflicts resolved. The changes in this PR are now identical to what's already in master, so there's no functional difference. Could you please take another look? Thanks!

@juicewcode
juicewcode requested a review from Aias00 September 20, 2026 14:27
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.

[BUG] DivideIngressParser protocol[i++] throws AIOOBE when protocol array shorter than endpoints

2 participants