[BUG] DubboIngressParser.parseUpstream NPE on null annotations / missing key / null backend guard
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 3.1k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 85
Description
## Description
Line 335: the null guard `Objects.nonNull(path) && Objects.nonNull(path.getBackend().getService())` calls `path.getBackend().getService()` without first checking `path.getBackend()` for null — if `getBackend()` is null, the guard itself NPEs. Line 339: `annotations.get(IngressConstants.UPSTREAMS_PROTOCOL_ANNOTATION_KEY).split(",")` — (a) `annotations` is passed from `ingress.getMetadata().getAnnotations()` which can be null (ingress with no annotations); (b) even if non-null, `.get()` returns null when the annotation is absent, and `.split(",")` on null NPEs. Contrast with `DivideIngressParser` (line 306) which null-guards both `annotations` and the key before splitting.
## Location
- `shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/DubboIngressParser.java:335,339`
## Impact
A Dubbo ingress without the `upstreams-protocol` annotation (the common case) NPEs during reconcile, preventing Dubbo routing from being configured.
## Suggested fix
Fix the guard to `Objects.nonNull(path) && Objects.nonNull(path.getBackend()) && Objects.nonNull(path.getBackend().getService())`. Guard line 339 with `if (Objects.nonNull(annotations) && annotations.containsKey(KEY))` before splitting, defaulting to `null` protocol (as `DivideIngressParser` does).
## Related existing
None — distinct from #6598 and GOV-T6 (#6679).
Contributor guide
No contributing guide indexed for this repository
Research direction
Open shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/DubboIngressParser.java around lines 335 and 339, then compare the null handling in DivideIngressParser around line 306. Verify that null backends, missing annotations, and absent upstreams-protocol keys no longer cause reconciliation to fail, with a null protocol used when the annotation is absent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kubernetes
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100