From 84a951b647756e48fac200cad7b655f04491dd0c Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Tue, 11 Feb 2014 21:25:14 +0000 Subject: [PATCH] Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud) 57701: Merged V4.2-BUG-FIX (4.2.1) to HEAD-BUG-FIX (Cloud/4.3) 57648: Merged V4.1-BUG-FIX (4.1.8) to V4.2-BUG-FIX (4.2.1) 57594: MNT-9770 : Merged from DEV to V4.1-BUG-FIX 57002: MNT-9770 : WebDAV uploads over 2gb in size fails. Change int type to long, as content length from http request more than Integer.MAX_VALUE . git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@61869 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/content/AbstractContentWriter.java | 5 ++--- .../alfresco/repo/content/LimitedStreamCopier.java | 13 ++++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/source/java/org/alfresco/repo/content/AbstractContentWriter.java b/source/java/org/alfresco/repo/content/AbstractContentWriter.java index 1ac28b67d4..2e514745f8 100644 --- a/source/java/org/alfresco/repo/content/AbstractContentWriter.java +++ b/source/java/org/alfresco/repo/content/AbstractContentWriter.java @@ -492,13 +492,12 @@ public abstract class AbstractContentWriter extends AbstractContentAccessor impl *

* Both streams are closed but any IOExceptions are thrown */ - private final int copyStreams(InputStream in, OutputStream out) throws IOException + private final long copyStreams(InputStream in, OutputStream out) throws IOException { ContentLimitProvider contentLimitProvider = getContentLimitProvider(); final long sizeLimit = contentLimitProvider.getSizeLimit(); - int byteCount = sizeLimitedStreamCopier.copyStreams(in, out, sizeLimit); - + long byteCount = sizeLimitedStreamCopier.copyStreamsLong(in, out, sizeLimit); return byteCount; } diff --git a/source/java/org/alfresco/repo/content/LimitedStreamCopier.java b/source/java/org/alfresco/repo/content/LimitedStreamCopier.java index d53f161f89..9756e7249c 100644 --- a/source/java/org/alfresco/repo/content/LimitedStreamCopier.java +++ b/source/java/org/alfresco/repo/content/LimitedStreamCopier.java @@ -51,7 +51,18 @@ public final class LimitedStreamCopier */ public final int copyStreams(InputStream in, OutputStream out, long sizeLimit) throws IOException { - int byteCount = 0; + long bytes = copyStreamsLong(in, out, sizeLimit); + if (bytes > Integer.MAX_VALUE) + { + throw new IllegalArgumentException(bytes + " cannot be cast to int."); + } + + return (int) bytes; + } + + public final long copyStreamsLong(InputStream in, OutputStream out, long sizeLimit) throws IOException + { + long byteCount = 0; IOException error = null; long totalBytesRead = 0;