wy471x opened a new pull request, #6892: URL: https://github.com/apache/shenyu/pull/6892
- DivideIngressParser: add bounds check when indexing protocol array, fall back to "http://" when annotation has fewer entries than endpoint addresses - DubboIngressParser: fix NPE when annotation is missing, fix double-increment bug where protocols[i++] was evaluated twice in one expression - Add unit tests covering missing, exact, fewer, mixed, and empty annotation scenarios <!-- Describe your PR here; e.g. Fixes #issueNo --> <!-- Thank you for proposing a pull request. This template will guide you through the essential steps necessary for a pull request. --> Make sure that: - [X] You have read the [contribution guidelines](https://shenyu.apache.org/community/contributor-guide). - [X] You submit test cases (unit or integration tests) that back your changes. - [X] Your local test passed `./mvnw clean install -Dmaven.javadoc.skip=true`. ## Summary ### Bug Fixes DivideIngressParser.java — The protocol array was indexed with protocol[i++] without any bounds check. When the shenyu.apache.org/upstreams-protocol annotation had fewer entries than endpoint addresses, it threw ArrayIndexOutOfBoundsException. Fixed by switching to an indexed for-loop with a bounds guard (i >= protocol.length) that falls back to "http://". DubboIngressParser.java — Two bugs fixed: 1. annotations.get(...).split(",") would NPE when the annotation was missing. Added null/containsKey guard, defaulting to "dubbo://". 2. protocols[i++] was evaluated twice in the same ternary expression (Objects.isNull(protocols[i++]) ? "dubbo://" : protocols[i++]), double-incrementing i and causing both skipped entries and AIOOBE. Replaced with a single bounds-checked protocols[i]. ### Unit Tests - DivideIngressParserTest.java — 5 tests: annotation missing, exact match, fewer entries than addresses, mixed protocols, empty annotation. - DubboIngressParserTest.java — 5 tests covering the same scenarios plus the previously-NPE case. close [#6485](https://github.com/apache/shenyu/issues/6485) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
