RFR: 8319531: FileServerHandler::discardRequestBody could be improved
Darragh Clarke
dclarke at openjdk.org
Fri Nov 10 15:31:08 UTC 2023
**Problem**
`discardRequestBody` calls `InputStream::readAllBytes` to read and discard all the request body bytes. This is somewhat wasteful as they can instead be skipped.
**Changes**
- Updated `FileServerHandler::discardRequestBody` to use `InputStream::skip`.
- Created skip in `LeftOverInputStream` based on [InputStream](https://github.com/openjdk/jdk/blob/c9657cad124d2be10b8d6006d0ca9a038b1c5945/src/java.base/share/classes/java/io/InputStream.java#L540). This gets used by `FixedLengthInputStream` and `ChunkedInputStream` which previously had been using the skip implementation from `FilteredInputStream` which would have caused blocking.
- Also made a minor change to `LeftOverInputStream::Drain` to change bufSize.
I ran test tiers 1-3 and all tests are passing with these changes
-------------
Commit messages:
- added a skip method for leftOverInputStream and altered drain method
Changes: https://git.openjdk.org/jdk/pull/16616/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=16616&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8319531
Stats: 30 lines in 2 files changed: 25 ins; 1 del; 4 mod
Patch: https://git.openjdk.org/jdk/pull/16616.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/16616/head:pull/16616
PR: https://git.openjdk.org/jdk/pull/16616
More information about the net-dev
mailing list