fix for Clirr report and keep [FILEUPLOAD-188] [FILEUPLOAD-195] fixed

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/fileupload/trunk@1455855 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/commons/fileupload/FileUploadBase.java b/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
index 29df0b7..cda9ade 100644
--- a/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
+++ b/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
@@ -952,8 +952,12 @@
 
             InputStream input = ctx.getInputStream();
 
+            @SuppressWarnings("deprecation") // still has to be backward compatible
+            final long requestSize = UploadContext.class.isAssignableFrom(ctx.getClass())
+                                     ? ((UploadContext) ctx).contentLength()
+                                     : ctx.getContentLength();
+
             if (sizeMax >= 0) {
-                long requestSize = ctx.contentLength();
                 if (requestSize != -1) {
                     if (requestSize > sizeMax) {
                         throw new SizeLimitExceededException(
@@ -985,8 +989,7 @@
                 throw new FileUploadException("the request was rejected because no multipart boundary was found");
             }
 
-            notifier = new MultipartStream.ProgressNotifier(listener,
-                    ctx.contentLength());
+            notifier = new MultipartStream.ProgressNotifier(listener, requestSize);
             multi = new MultipartStream(input, boundary, notifier);
             multi.setHeaderEncoding(charEncoding);
 
diff --git a/src/main/java/org/apache/commons/fileupload/RequestContext.java b/src/main/java/org/apache/commons/fileupload/RequestContext.java
index 692693b..b652ff9 100644
--- a/src/main/java/org/apache/commons/fileupload/RequestContext.java
+++ b/src/main/java/org/apache/commons/fileupload/RequestContext.java
@@ -50,20 +50,12 @@
      * Retrieve the content length of the request.
      *
      * @return The content length of the request.
-     * @deprecated 1.3 Use {@link #contentLength()} instead
+     * @deprecated 1.3 Use {@link UploadContext#contentLength()} instead
      */
     @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.
diff --git a/src/main/java/org/apache/commons/fileupload/UploadContext.java b/src/main/java/org/apache/commons/fileupload/UploadContext.java
new file mode 100644
index 0000000..df13367
--- /dev/null
+++ b/src/main/java/org/apache/commons/fileupload/UploadContext.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.fileupload;
+
+/**
+ * Enhanced access to the request information needed for file uploads,
+ * which fixes the Content Length data access in {@link RequestContext}.
+ *
+ * @since 1.3
+ */
+public interface UploadContext extends RequestContext {
+
+    /**
+     * Retrieve the content length of the request.
+     *
+     * @return The content length of the request.
+     * @since 1.3
+     */
+    long contentLength();
+
+}
diff --git a/src/main/java/org/apache/commons/fileupload/portlet/PortletRequestContext.java b/src/main/java/org/apache/commons/fileupload/portlet/PortletRequestContext.java
index 7509990..285d785 100644
--- a/src/main/java/org/apache/commons/fileupload/portlet/PortletRequestContext.java
+++ b/src/main/java/org/apache/commons/fileupload/portlet/PortletRequestContext.java
@@ -18,12 +18,13 @@
 
 import static java.lang.String.format;
 
-import java.io.InputStream;
 import java.io.IOException;
+import java.io.InputStream;
+
 import javax.portlet.ActionRequest;
 
 import org.apache.commons.fileupload.FileUploadBase;
-import org.apache.commons.fileupload.RequestContext;
+import org.apache.commons.fileupload.UploadContext;
 
 /**
  * <p>Provides access to the request information needed for a request made to
@@ -33,7 +34,7 @@
  *
  * @version $Id$
  */
-public class PortletRequestContext implements RequestContext {
+public class PortletRequestContext implements UploadContext {
 
     // ----------------------------------------------------- Instance Variables
 
diff --git a/src/main/java/org/apache/commons/fileupload/servlet/ServletRequestContext.java b/src/main/java/org/apache/commons/fileupload/servlet/ServletRequestContext.java
index 894a385..5619653 100644
--- a/src/main/java/org/apache/commons/fileupload/servlet/ServletRequestContext.java
+++ b/src/main/java/org/apache/commons/fileupload/servlet/ServletRequestContext.java
@@ -24,7 +24,7 @@
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.commons.fileupload.FileUploadBase;
-import org.apache.commons.fileupload.RequestContext;
+import org.apache.commons.fileupload.UploadContext;
 
 /**
  * <p>Provides access to the request information needed for a request made to
@@ -34,7 +34,7 @@
  *
  * @version $Id$
  */
-public class ServletRequestContext implements RequestContext {
+public class ServletRequestContext implements UploadContext {
 
     // ----------------------------------------------------- Instance Variables