On Mon, 7 Jul 2025 08:36:51 GMT, Daniel Fuchs <dfu...@openjdk.org> wrote:
>> Volkan Yazici has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Implement review feedback > > src/java.net.http/share/classes/jdk/internal/net/http/RequestPublishers.java > line 488: > >> 486: ByteBuffer buffer = Utils.BUFSIZE > remaining >> 487: ? Utils.getBufferWithAtMost((int) remaining) >> 488: : Utils.getBuffer(); > > I suggest to change `Utils.getBufferWithAtMost` to take a long instead of an > int, and replace the ternary operator here with simply: > > ByteBuffer buffer = Utils.getBufferWithAtMost(remaining); Implemented in 0eda56f18a2. > src/java.net.http/share/classes/jdk/internal/net/http/common/Utils.java line > 386: > >> 384: * @throws IllegalArgumentException if {@code capacity < 0} >> 385: */ >> 386: public static ByteBuffer getBufferWithAtMost(int maxCapacity) { > > Suggestion: > > public static ByteBuffer getBufferWithAtMost(long maxCapacity) { > > > We could accept `long` here. Implemented in 0eda56f18a2. > src/java.net.http/share/classes/jdk/internal/net/http/common/Utils.java line > 392: > >> 390: "capacity < 0: (%s < 0)".formatted(maxCapacity)); >> 391: } >> 392: int effectiveCapacity = Math.clamp(maxCapacity, 0, BUFSIZE); > > Suggestion: > > int effectiveCapacity = (int) Math.min(maxCapacity, (long) BUFSIZE); > > Use Math.min(long,long) - since BUFZIZE is an int we can safely cast back to > int. No need to clamp at 0 since we verified maxCapacity >= 0 Implemented in 0eda56f18a2. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/26155#discussion_r2189487270 PR Review Comment: https://git.openjdk.org/jdk/pull/26155#discussion_r2189487509 PR Review Comment: https://git.openjdk.org/jdk/pull/26155#discussion_r2189487815