]> source.dussan.org Git - jgit.git/commitdiff
Fix IllegalArgumentException in AmazonS3 46/44546/2
authorMatthias Sohn <matthias.sohn@sap.com>
Wed, 25 Mar 2015 00:31:12 +0000 (01:31 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Thu, 9 Apr 2015 09:12:01 +0000 (11:12 +0200)
JGit hit IllegalArgumentException: invalid content length
when pushing large packs to S3.

Bug: 463015
Change-Id: Iddf50d90c7e3ccb15b9ff71233338c6b204b3648
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java

index 705a84613cf522e332d4fc79883a95338e83f0c6..f43ea637aaaab3b619977896787785a81349f049 100644 (file)
@@ -489,16 +489,14 @@ public class AmazonS3 {
 
                final String md5str = Base64.encodeBytes(csum);
                final long len = buf.length();
-               final String lenstr = String.valueOf(len);
                for (int curAttempt = 0; curAttempt < maxAttempts; curAttempt++) {
                        final HttpURLConnection c = open("PUT", bucket, key); //$NON-NLS-1$
-                       c.setRequestProperty("Content-Length", lenstr); //$NON-NLS-1$
+                       c.setFixedLengthStreamingMode(len);
                        c.setRequestProperty("Content-MD5", md5str); //$NON-NLS-1$
                        c.setRequestProperty(X_AMZ_ACL, acl);
                        encryption.request(c, X_AMZ_META);
                        authorize(c);
                        c.setDoOutput(true);
-                       c.setFixedLengthStreamingMode((int) len);
                        monitor.beginTask(monitorTask, (int) (len / 1024));
                        final OutputStream os = c.getOutputStream();
                        try {