You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ma...@apache.org on 2005/11/28 00:54:12 UTC

svn commit: r349333 - /jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/FileUploadBase.java

Author: martinc
Date: Sun Nov 27 15:54:10 2005
New Revision: 349333

URL: http://svn.apache.org/viewcvs?rev=349333&view=rev
Log:
Bugzilla #32782 - Include the actual and permitted sizes in both the exception message and the exception itself.

Modified:
    jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/FileUploadBase.java

Modified: jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/FileUploadBase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/FileUploadBase.java?rev=349333&r1=349332&r2=349333&view=diff
==============================================================================
--- jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/FileUploadBase.java (original)
+++ jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/FileUploadBase.java Sun Nov 27 15:54:10 2005
@@ -308,8 +308,9 @@
 
         if (sizeMax >= 0 && requestSize > sizeMax) {
             throw new SizeLimitExceededException(
-                "the request was rejected because "
-                + "its size exceeds allowed range");
+                "the request was rejected because its size (" + requestSize
+                + ") exceeds the configured maximum (" + sizeMax + ")",
+                requestSize, sizeMax);
         }
 
         String charEncoding = headerEncoding;
@@ -633,6 +634,16 @@
     public static class SizeLimitExceededException
         extends FileUploadException {
         /**
+         * The actual size of the request.
+         */
+        private long actual;
+
+        /**
+         * The maximum permitted size of the request.
+         */
+        private long permitted;
+
+        /**
          * Constructs a <code>SizeExceededException</code> with no
          * detail message.
          */
@@ -641,13 +652,46 @@
         }
 
         /**
-         * Constructs an <code>SizeExceededException</code> with
+         * Constructs a <code>SizeExceededException</code> with
          * the specified detail message.
          *
          * @param message The detail message.
          */
         public SizeLimitExceededException(String message) {
             super(message);
+        }
+
+        /**
+         * Constructs a <code>SizeExceededException</code> with
+         * the specified detail message, and actual and permitted sizes.
+         *
+         * @param message   The detail message.
+         * @param actual    The actual request size.
+         * @param permitted The maximum permitted request size.
+         */
+        public SizeLimitExceededException(String message, long actual,
+                long permitted) {
+            super(message);
+            this.actual = actual;
+            this.permitted = permitted;
+        }
+
+        /**
+         * Retrieves the actual size of the request.
+         *
+         * @return The actual size of the request.
+         */
+        public long getActualSize() {
+            return actual;
+        }
+
+        /**
+         * Retrieves the permitted size of the request.
+         *
+         * @return The permitted size of the request.
+         */
+        public long getPermittedSize() {
+            return permitted;
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org