Skip to content

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

Description

@Aias00

Description

In parseUpstream, the protocol array is populated from annotations.get(UPSTREAMS_PROTOCOL_ANNOTATION_KEY).split(",") (line 307). Then for each endpoint address, line 325 does protocol[i++] where i increments per address. If the user provides fewer comma-separated protocol values than there are endpoint addresses (e.g. 2 protocols for 3 endpoints), i exceeds the array bounds and throws ArrayIndexOutOfBoundsException. The sibling DubboIngressParser (line 348-349) has the same protocol[i++] pattern.

Location

  • shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/DivideIngressParser.java:325 (same at DubboIngressParser.java:348-349)

Impact

An ingress with a mismatched upstreams-protocol annotation (fewer protocols than endpoints) crashes the reconcile, blocking route configuration.

Suggested fix

Guard with protocol.length > i ? protocol[i++] : "http://" (or cycle: protocol[i % protocol.length]), and add a bounds check.

Related existing

None — #6598 covers http:// hardcode in EndpointsReconciler; this is an AIOOBE in the parser.

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