> Adds a new `ofFileChannel(FileChannel channel, long offset, long length)`
> method to `java.net.HttpRequest.BodyPublishers` to provide an `HttpClient`
> publisher to upload a certain region of a file. The new publisher does not
> modify the state of the passed `FileChannel`, streams the file channel bytes
> as it publishes (i.e., avoids reading the entire file into the memory), and
> can be leveraged to implement sliced uploads. As noted in the Javadoc:
>
>> The file channel will not be closed upon completion. The caller is
>> expected to manage the life cycle of the channel, and close it
>> appropriately when not needed anymore.
>
> ### Implementation notes
>
> - `FileChannel` is preferred over `{Readable,Seekable}ByteChannel`, since the
> latter does not provide a positional read without modifying the state of the
> `FileChannel`, which is necessary to use a single `FileChannel` instance to
> implement sliced uploads.
> - `ofFileChannel(FileChannel,long,long)` is preferred over
> `ofPath(Path,long,long)` to avoid overloading the maximum file descriptor
> limit of the platform.
Volkan Yazici has updated the pull request with a new target base due to a
merge or a rebase. The incremental webrev excludes the unrelated changes
brought in by the merge/rebase. The pull request contains 18 additional commits
since the last revision:
- Merge remote-tracking branch 'upstream/master' into ofFileChannel
- Improve Javadoc
- Improve `@apiNote`
- Improve the `ofFileChannel` Javadoc
- Improve style for declaring multiple consecutive fields of the same type
- Revert the last commit: faa5d24d831
The `send()`-vs-`sendAsync()` discrepancy will be addressed separately.
- Verify exceptions using both `send()` and `sendAsync()`
- Replace usage of `CompletableFuture` with `Future`
- Apply review feedback for `FileChannelPublisherTest`
- Fix typo in `Utils::getBufferWithAtMost` Javadoc
- ... and 8 more: https://git.openjdk.org/jdk/compare/31c7b765...838b8ca7
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/26155/files
- new: https://git.openjdk.org/jdk/pull/26155/files/53b22972..838b8ca7
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=26155&range=11
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=26155&range=10-11
Stats: 101758 lines in 2448 files changed: 61263 ins; 27410 del; 13085 mod
Patch: https://git.openjdk.org/jdk/pull/26155.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/26155/head:pull/26155
PR: https://git.openjdk.org/jdk/pull/26155