From 99d54c6631ab6facb17f2f3fe270bd331820366d Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 24 Oct 2014 16:31:31 -0700 Subject: [PATCH] Revert "JCLOUDS-264: Allow payloads greater than 2 GB" This reverts commit 7e4cacf9ea12d697d6c48b83a28c12d47ab8cfae. --- .../internal/JavaUrlHttpCommandExecutorService.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java b/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java index d29927ffc9..b326bc7cc3 100644 --- a/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java +++ b/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java @@ -16,6 +16,7 @@ */ package org.jclouds.http.internal; +import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Throwables.propagate; import static com.google.common.io.ByteStreams.toByteArray; @@ -177,10 +178,15 @@ public class JavaUrlHttpCommandExecutorService extends BaseHttpCommandExecutorSe connection.setChunkedStreamingMode(8196); writePayloadToConnection(payload, "streaming", connection); } else { - long length = checkNotNull(md.getContentLength(), "payload.getContentLength"); + Long length = checkNotNull(md.getContentLength(), "payload.getContentLength"); + // TODO: remove check after moving to JDK 7. + checkArgument(length <= Integer.MAX_VALUE, + "Cannot transfer 2 GB or larger chunks due to JDK 1.6 limitations." + + " Use chunked encoding or multi-part upload, if possible." + + " For more information: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6755625"); if (length > 0) { - connection.setRequestProperty(CONTENT_LENGTH, String.valueOf(length)); - connection.setFixedLengthStreamingMode(length); + connection.setRequestProperty(CONTENT_LENGTH, length.toString()); + connection.setFixedLengthStreamingMode(length.intValue()); writePayloadToConnection(payload, length, connection); } else { writeNothing(connection);