hickey-ai opened a new pull request, #16511: URL: https://github.com/apache/dubbo/pull/16511
## What is the purpose of the change? Addresses #16510. `StreamUtils.limitedInputStream` treats `available()` as the total length, advances its position by the requested byte count rather than the delegate's actual progress, and reports EOF for a zero-length read at the limit. A legal short read/skip can therefore exhaust the limit early or report bytes that were never read. `skipUnusedStream` also stops after a partial skip. - Keep the requested limit independently of currently available bytes; cap `available()` to both the delegate estimate and remaining limit. - Account for the actual return values of single-byte reads, bulk reads, and skips. Preserve zero-length-read and EOF behavior and do not consume beyond the limit. - Complete short skips of the **initially available** cleanup budget, using a one-byte fallback when `skip()` makes no progress. Do not wait for future bytes or read an unbounded network stream to EOF. **Scope clarification for #16510:** `available() == 0` does not establish EOF, but this PR intentionally keeps cleanup restricted to bytes already available. A future-data draining change would alter its blocking semantics and is not proposed. The `limitedInputStream` read path still reads up to the requested limit even when its initial `available()` is zero. ## Validation Added nine focused regression/control cases in the existing `StreamUtilsTest`. Before the implementation change: 15 tests, 6 assertion failures, 0 errors/skips. After: all 15 pass. Executed on Windows 11 / OpenJDK 21 / Maven 3.6.3, against current `3.3` source: ```text mvn -B -pl dubbo-common -am -Dtest=StreamUtilsTest -Dsurefire.failIfNoSpecifiedTests=false test mvn -B -pl dubbo-remoting/dubbo-remoting-api -am -Dtest=org.apache.dubbo.common.io.*Test,ExchangeCodecTest,ChannelBufferInputStreamTest -Dsurefire.failIfNoSpecifiedTests=false test ``` The broader run produced 7 Surefire suites: **85 tests, 82 passed, 3 pre-existing skips in ExchangeCodecTest, 0 failures/errors**. Formatting checks in the Maven test lifecycle and `git diff --check` passed. This is scoped module/caller regression verification, not the full repository suite or a production network test. Upstream GitHub Actions remain to be verified. ## Checklist - [x] Reference the reported issue and explain the blocking-semantics boundary. - [x] Add regression tests that fail before the fix and pass afterward. - [x] Run the affected I/O and exchange-codec regression tests locally. - [x] Check formatting and whitespace. - [ ] Upstream GitHub Actions completed successfully. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
