fix: guard ingress upstream protocol index (#6864) - #6966
juicewcode wants to merge 10 commits into
Conversation
Prevent Divide and Dubbo ingress parsers from throwing ArrayIndexOutOfBoundsException when fewer protocols than endpoints are configured. Fall back to http:// and dubbo:// respectively.
Aias00
left a comment
There was a problem hiding this comment.
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.
|
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. |
Aias00
left a comment
There was a problem hiding this comment.
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
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! |
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:
./mvnw clean install -Dmaven.javadoc.skip=true.