fix: guard ingress upstream protocol index (#6864) - #6966
Open
juicewcode wants to merge 3 commits into
Open
Conversation
Prevent Divide and Dubbo ingress parsers from throwing ArrayIndexOutOfBoundsException when fewer protocols than endpoints are configured. Fall back to http:// and dubbo:// respectively.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.