Skip to content

Commit

Permalink
Prefer Java 9 InputStream.readAllBytes
Browse files Browse the repository at this point in the history
  • Loading branch information
gaul committed Nov 24, 2024
1 parent 595a7f9 commit 83bc9f7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/main/java/org/gaul/s3proxy/NullBlobStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.hash.HashCode;
import com.google.common.io.ByteSource;
import com.google.common.io.ByteStreams;
import com.google.common.primitives.Longs;

import org.jclouds.blobstore.BlobStore;
Expand Down Expand Up @@ -81,7 +80,7 @@ public Blob getBlob(String container, String name, GetOptions options) {

byte[] array;
try (InputStream is = blob.getPayload().openStream()) {
array = ByteStreams.toByteArray(is);
array = is.readAllBytes();
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/gaul/s3proxy/S3ProxyHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,8 @@ public final void doHandle(HttpServletRequest baseRequest,
} else {
// buffer the entire stream to calculate digest
// why input stream read contentlength of header?
payload = ByteStreams.toByteArray(ByteStreams.limit(
is, v4MaxNonChunkedRequestSize + 1));
payload = ByteStreams.limit(is, v4MaxNonChunkedRequestSize + 1)
.readAllBytes();
if (payload.length == v4MaxNonChunkedRequestSize + 1) {
throw new S3Exception(
S3ErrorCode.MAX_MESSAGE_LENGTH_EXCEEDED);
Expand Down

0 comments on commit 83bc9f7

Please sign in to comment.