You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2013/03/06 11:52:06 UTC
svn commit: r1453285 - in /commons/proper/fileupload/trunk: ./ src/changes/
src/main/java/org/apache/commons/fileupload/
src/main/java/org/apache/commons/fileupload/portlet/
src/main/java/org/apache/commons/fileupload/servlet/
src/test/java/org/apache/...
Author: simonetripodi
Date: Wed Mar 6 10:52:05 2013
New Revision: 1453285
URL: http://svn.apache.org/r1453285
Log:
[FILEUPLOAD-195] #comment Error reading the file size larger than 2 gb - this is enought to justify the bump to 1.3 version #resolve
Modified:
commons/proper/fileupload/trunk/pom.xml
commons/proper/fileupload/trunk/src/changes/changes.xml
commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/RequestContext.java
commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/portlet/PortletRequestContext.java
commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/servlet/ServletRequestContext.java
commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/MockHttpServletRequest.java
Modified: commons/proper/fileupload/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/pom.xml?rev=1453285&r1=1453284&r2=1453285&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/pom.xml (original)
+++ commons/proper/fileupload/trunk/pom.xml Wed Mar 6 10:52:05 2013
@@ -26,7 +26,7 @@
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
- <version>1.2.3-SNAPSHOT</version>
+ <version>1.3-SNAPSHOT</version>
<name>Commons FileUpload</name>
<description>
Modified: commons/proper/fileupload/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/changes/changes.xml?rev=1453285&r1=1453284&r2=1453285&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/changes/changes.xml (original)
+++ commons/proper/fileupload/trunk/src/changes/changes.xml Wed Mar 6 10:52:05 2013
@@ -43,7 +43,7 @@ The <action> type attribute can be add,u
</properties>
<body>
- <release version="1.2.3-SNAPSHOT">
+ <release version="1.3-SNAPSHOT">
<action dev="simonetripodi" type="add" issue="FILEUPLOAD-218">
Update version in POM
</action>
Modified: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileUploadBase.java?rev=1453285&r1=1453284&r2=1453285&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileUploadBase.java (original)
+++ commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileUploadBase.java Wed Mar 6 10:52:05 2013
@@ -918,7 +918,7 @@ public abstract class FileUploadBase {
InputStream input = ctx.getInputStream();
if (sizeMax >= 0) {
- int requestSize = ctx.getContentLength();
+ long requestSize = ctx.contentLength();
if (requestSize == -1) {
input = new LimitedInputStream(input, sizeMax) {
@Override
@@ -952,7 +952,7 @@ public abstract class FileUploadBase {
}
notifier = new MultipartStream.ProgressNotifier(listener,
- ctx.getContentLength());
+ ctx.contentLength());
multi = new MultipartStream(input, boundary, notifier);
multi.setHeaderEncoding(charEncoding);
Modified: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/RequestContext.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/RequestContext.java?rev=1453285&r1=1453284&r2=1453285&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/RequestContext.java (original)
+++ commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/RequestContext.java Wed Mar 6 10:52:05 2013
@@ -50,10 +50,21 @@ public interface RequestContext {
* Retrieve the content length of the request.
*
* @return The content length of the request.
+ * @deprecated
+ * @see #contentLength()
*/
+ @Deprecated
int getContentLength();
/**
+ * Retrieve the content length of the request.
+ *
+ * @return The content length of the request.
+ * @since 1.3
+ */
+ long contentLength();
+
+ /**
* Retrieve the input stream for the request.
*
* @return The input stream for the request.
Modified: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/portlet/PortletRequestContext.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/portlet/PortletRequestContext.java?rev=1453285&r1=1453284&r2=1453285&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/portlet/PortletRequestContext.java (original)
+++ commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/portlet/PortletRequestContext.java Wed Mar 6 10:52:05 2013
@@ -21,6 +21,8 @@ import static java.lang.String.format;
import java.io.InputStream;
import java.io.IOException;
import javax.portlet.ActionRequest;
+
+import org.apache.commons.fileupload.FileUploadBase;
import org.apache.commons.fileupload.RequestContext;
/**
@@ -79,12 +81,31 @@ public class PortletRequestContext imple
* Retrieve the content length of the request.
*
* @return The content length of the request.
+ * @deprecated
+ * @see #contentLength()
*/
+ @Deprecated
public int getContentLength() {
return request.getContentLength();
}
/**
+ * Retrieve the content length of the request.
+ *
+ * @return The content length of the request.
+ * @since 1.3
+ */
+ public long contentLength() {
+ long size;
+ try {
+ size = Long.parseLong(request.getProperty(FileUploadBase.CONTENT_LENGTH));
+ } catch (NumberFormatException e) {
+ size = -1;
+ }
+ return size;
+ }
+
+ /**
* Retrieve the input stream for the request.
*
* @return The input stream for the request.
Modified: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/servlet/ServletRequestContext.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/servlet/ServletRequestContext.java?rev=1453285&r1=1453284&r2=1453285&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/servlet/ServletRequestContext.java (original)
+++ commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/servlet/ServletRequestContext.java Wed Mar 6 10:52:05 2013
@@ -18,9 +18,12 @@ package org.apache.commons.fileupload.se
import static java.lang.String.format;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
+
import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.fileupload.FileUploadBase;
import org.apache.commons.fileupload.RequestContext;
/**
@@ -77,12 +80,31 @@ public class ServletRequestContext imple
* Retrieve the content length of the request.
*
* @return The content length of the request.
+ * @deprecated
+ * @see #contentLength()
*/
+ @Deprecated
public int getContentLength() {
return request.getContentLength();
}
/**
+ * Retrieve the content length of the request.
+ *
+ * @return The content length of the request.
+ * @since 1.3
+ */
+ public long contentLength() {
+ long size;
+ try {
+ size = Long.parseLong(request.getHeader(FileUploadBase.CONTENT_LENGTH));
+ } catch (NumberFormatException e) {
+ size = -1;
+ }
+ return size;
+ }
+
+ /**
* Retrieve the input stream for the request.
*
* @return The input stream for the request.
@@ -101,7 +123,7 @@ public class ServletRequestContext imple
@Override
public String toString() {
return format("ContentLength=%s, ContentType=%s",
- this.getContentLength(),
+ this.contentLength(),
this.getContentType());
}
Modified: commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/MockHttpServletRequest.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/MockHttpServletRequest.java?rev=1453285&r1=1453284&r2=1453285&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/MockHttpServletRequest.java (original)
+++ commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/MockHttpServletRequest.java Wed Mar 6 10:52:05 2013
@@ -44,7 +44,7 @@ class MockHttpServletRequest implements
{
private final InputStream m_requestData;
- private final int length;
+ private final long length;
private String m_strContentType;
private final Map<String, String> m_headers = new java.util.HashMap<String, String>();
@@ -66,7 +66,7 @@ class MockHttpServletRequest implements
*/
public MockHttpServletRequest(
final InputStream requestData,
- final int requestLength,
+ final long requestLength,
final String strContentType)
{
m_requestData = requestData;
@@ -324,7 +324,10 @@ class MockHttpServletRequest implements
}
else
{
- iLength = length;
+ if (length > Integer.MAX_VALUE) {
+ throw new RuntimeException("Value '" + length + "' is too large to be converted to int");
+ }
+ iLength = (int) length;
}
return iLength;
}