[BUG] DivideIngressParser protocol[i++] throws AIOOBE when protocol array shorter than endpoints
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 3.1k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 85
Description
## 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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/DivideIngressParser.java at parseUpstream and compare the protocol indexing with DubboIngressParser.java:348-349. Reproduce an annotation with fewer protocol values than endpoint addresses, then verify reconciliation no longer throws ArrayIndexOutOfBoundsException and route configuration continues.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100