InputStream.readAllBytes() allows us to avoid the creation of an intermediate ByteArrayOutputStream and is likely to perform better.

Comment From: sbrannen

This has been merged into main.

Thanks

Comment From: edudar-chwy

One caveat is that it might be faster but also greedier. With this implementation, when one tries to read all bytes from an uploaded file, the underlying ChannelInputStream allocates a direct buffer of the file's size. With large enough files, that requires a pretty significant MaxDirectMemorySize setting. The memory calculator used by java-buildpack blocks out that memory, and this is not optimal when running in low-footprint containers.