Skip to content

Commit 83bc9f7

Browse files
committed
Prefer Java 9 InputStream.readAllBytes
1 parent 595a7f9 commit 83bc9f7

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/main/java/org/gaul/s3proxy/NullBlobStore.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import com.google.common.collect.ImmutableSet;
2929
import com.google.common.hash.HashCode;
3030
import com.google.common.io.ByteSource;
31-
import com.google.common.io.ByteStreams;
3231
import com.google.common.primitives.Longs;
3332

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

8281
byte[] array;
8382
try (InputStream is = blob.getPayload().openStream()) {
84-
array = ByteStreams.toByteArray(is);
83+
array = is.readAllBytes();
8584
} catch (IOException ioe) {
8685
throw new RuntimeException(ioe);
8786
}

src/main/java/org/gaul/s3proxy/S3ProxyHandler.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,8 @@ public final void doHandle(HttpServletRequest baseRequest,
577577
} else {
578578
// buffer the entire stream to calculate digest
579579
// why input stream read contentlength of header?
580-
payload = ByteStreams.toByteArray(ByteStreams.limit(
581-
is, v4MaxNonChunkedRequestSize + 1));
580+
payload = ByteStreams.limit(is, v4MaxNonChunkedRequestSize + 1)
581+
.readAllBytes();
582582
if (payload.length == v4MaxNonChunkedRequestSize + 1) {
583583
throw new S3Exception(
584584
S3ErrorCode.MAX_MESSAGE_LENGTH_EXCEEDED);

0 commit comments

Comments
 (0)