This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-fileupload.git

commit 0324d010e6834d03db76941b0ad0d8c505a17630
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Tue Apr 4 18:54:25 2023 -0400

    Pull up method into super-interface and remove per Javadoc
    
    Rename getter
---
 .../apache/commons/fileupload2/RequestContext.java |  8 +++++
 .../apache/commons/fileupload2/UploadContext.java  | 39 ----------------------
 .../fileupload2/impl/FileItemIteratorImpl.java     |  7 ++--
 .../jaksrvlt/JakSrvltRequestContext.java           |  8 ++---
 .../fileupload2/portlet/PortletRequestContext.java |  8 ++---
 .../fileupload2/servlet/ServletRequestContext.java |  8 ++---
 6 files changed, 23 insertions(+), 55 deletions(-)

diff --git a/src/main/java/org/apache/commons/fileupload2/RequestContext.java 
b/src/main/java/org/apache/commons/fileupload2/RequestContext.java
index 46094ca..99f9070 100644
--- a/src/main/java/org/apache/commons/fileupload2/RequestContext.java
+++ b/src/main/java/org/apache/commons/fileupload2/RequestContext.java
@@ -35,6 +35,14 @@ public interface RequestContext {
      */
     String getCharacterEncoding();
 
+    /**
+     * Gets the content length of the request.
+     *
+     * @return The content length of the request.
+     * @since 1.3
+     */
+    long getContentLength();
+
     /**
      * Gets the content type of the request.
      *
diff --git a/src/main/java/org/apache/commons/fileupload2/UploadContext.java 
b/src/main/java/org/apache/commons/fileupload2/UploadContext.java
deleted file mode 100644
index 08e9cde..0000000
--- a/src/main/java/org/apache/commons/fileupload2/UploadContext.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.fileupload2;
-
-/**
- * Enhanced access to the request information needed for file uploads,
- * which fixes the Content Length data access in {@link RequestContext}.
- *
- * The reason of introducing this new interface is just for backward 
compatibility
- * and it might vanish for a refactored 2.x version moving the new method into
- * RequestContext again.
- *
- * @since 1.3
- */
-public interface UploadContext extends RequestContext {
-
-    /**
-     * Gets 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/fileupload2/impl/FileItemIteratorImpl.java 
b/src/main/java/org/apache/commons/fileupload2/impl/FileItemIteratorImpl.java
index 90e6773..fff73e9 100644
--- 
a/src/main/java/org/apache/commons/fileupload2/impl/FileItemIteratorImpl.java
+++ 
b/src/main/java/org/apache/commons/fileupload2/impl/FileItemIteratorImpl.java
@@ -35,7 +35,6 @@ import org.apache.commons.fileupload2.FileUploadException;
 import org.apache.commons.fileupload2.MultipartStream;
 import org.apache.commons.fileupload2.ProgressListener;
 import org.apache.commons.fileupload2.RequestContext;
-import org.apache.commons.fileupload2.UploadContext;
 import org.apache.commons.fileupload2.pub.FileUploadContentTypeException;
 import org.apache.commons.fileupload2.pub.FileUploadSizeException;
 import org.apache.commons.fileupload2.util.LimitedInputStream;
@@ -256,11 +255,11 @@ public class FileItemIteratorImpl implements 
FileItemIterator {
             throw new FileUploadContentTypeException(format("the request 
doesn't contain a %s or %s stream, content type header is %s",
                     FileUploadBase.MULTIPART_FORM_DATA, 
FileUploadBase.MULTIPART_MIXED, contentType), contentType);
         }
-        final long contentLengthInt = ((UploadContext) ctx).contentLength();
+        final long contentLengthInt = ctx.getContentLength();
         // @formatter:off
-        final long requestSize = 
UploadContext.class.isAssignableFrom(ctx.getClass())
+        final long requestSize = 
RequestContext.class.isAssignableFrom(ctx.getClass())
                                  // Inline conditional is OK here 
CHECKSTYLE:OFF
-                                 ? ((UploadContext) ctx).contentLength()
+                                 ? ctx.getContentLength()
                                  : contentLengthInt;
                                  // CHECKSTYLE:ON
         // @formatter:on
diff --git 
a/src/main/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltRequestContext.java
 
b/src/main/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltRequestContext.java
index f2b6685..6faf0e1 100644
--- 
a/src/main/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltRequestContext.java
+++ 
b/src/main/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltRequestContext.java
@@ -22,7 +22,7 @@ import java.io.IOException;
 import java.io.InputStream;
 
 import org.apache.commons.fileupload2.FileUploadBase;
-import org.apache.commons.fileupload2.UploadContext;
+import org.apache.commons.fileupload2.RequestContext;
 
 import jakarta.servlet.http.HttpServletRequest;
 
@@ -32,7 +32,7 @@ import jakarta.servlet.http.HttpServletRequest;
  *
  * @since 1.1
  */
-public class JakSrvltRequestContext implements UploadContext {
+public class JakSrvltRequestContext implements RequestContext {
 
     /**
      * The request for which the context is being provided.
@@ -55,7 +55,7 @@ public class JakSrvltRequestContext implements UploadContext {
      * @since 1.3
      */
     @Override
-    public long contentLength() {
+    public long getContentLength() {
         long size;
         try {
             size = 
Long.parseLong(request.getHeader(FileUploadBase.CONTENT_LENGTH));
@@ -105,7 +105,7 @@ public class JakSrvltRequestContext implements 
UploadContext {
     @Override
     public String toString() {
         return format("ContentLength=%s, ContentType=%s",
-                this.contentLength(),
+                this.getContentLength(),
                 this.getContentType());
     }
 
diff --git 
a/src/main/java/org/apache/commons/fileupload2/portlet/PortletRequestContext.java
 
b/src/main/java/org/apache/commons/fileupload2/portlet/PortletRequestContext.java
index 455dbf6..064fda8 100644
--- 
a/src/main/java/org/apache/commons/fileupload2/portlet/PortletRequestContext.java
+++ 
b/src/main/java/org/apache/commons/fileupload2/portlet/PortletRequestContext.java
@@ -24,7 +24,7 @@ import java.io.InputStream;
 import javax.portlet.ActionRequest;
 
 import org.apache.commons.fileupload2.FileUploadBase;
-import org.apache.commons.fileupload2.UploadContext;
+import org.apache.commons.fileupload2.RequestContext;
 
 /**
  * Provides access to the request information needed for a request made to
@@ -32,7 +32,7 @@ import org.apache.commons.fileupload2.UploadContext;
  *
  * @since 1.1
  */
-public class PortletRequestContext implements UploadContext {
+public class PortletRequestContext implements RequestContext {
 
     /**
      * The request for which the context is being provided.
@@ -55,7 +55,7 @@ public class PortletRequestContext implements UploadContext {
      * @since 1.3
      */
     @Override
-    public long contentLength() {
+    public long getContentLength() {
         long size;
         try {
             size = 
Long.parseLong(request.getProperty(FileUploadBase.CONTENT_LENGTH));
@@ -105,7 +105,7 @@ public class PortletRequestContext implements UploadContext 
{
     @Override
     public String toString() {
         return format("ContentLength=%s, ContentType=%s",
-                this.contentLength(),
+                this.getContentLength(),
                       this.getContentType());
     }
 
diff --git 
a/src/main/java/org/apache/commons/fileupload2/servlet/ServletRequestContext.java
 
b/src/main/java/org/apache/commons/fileupload2/servlet/ServletRequestContext.java
index 7b9ffca..86f36f5 100644
--- 
a/src/main/java/org/apache/commons/fileupload2/servlet/ServletRequestContext.java
+++ 
b/src/main/java/org/apache/commons/fileupload2/servlet/ServletRequestContext.java
@@ -24,7 +24,7 @@ import java.io.InputStream;
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.commons.fileupload2.FileUploadBase;
-import org.apache.commons.fileupload2.UploadContext;
+import org.apache.commons.fileupload2.RequestContext;
 
 /**
  * Provides access to the request information needed for a request made to
@@ -32,7 +32,7 @@ import org.apache.commons.fileupload2.UploadContext;
  *
  * @since 1.1
  */
-public class ServletRequestContext implements UploadContext {
+public class ServletRequestContext implements RequestContext {
 
     /**
      * The request for which the context is being provided.
@@ -55,7 +55,7 @@ public class ServletRequestContext implements UploadContext {
      * @since 1.3
      */
     @Override
-    public long contentLength() {
+    public long getContentLength() {
         long size;
         try {
             size = 
Long.parseLong(request.getHeader(FileUploadBase.CONTENT_LENGTH));
@@ -105,7 +105,7 @@ public class ServletRequestContext implements UploadContext 
{
     @Override
     public String toString() {
         return format("ContentLength=%s, ContentType=%s",
-                this.contentLength(),
+                this.getContentLength(),
                 this.getContentType());
     }
 

Reply via email to