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

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

commit d8b90d3496bb4791d8dbbe84a03a470617aa3b92
Author: Gary D. Gregory <garydgreg...@gmail.com>
AuthorDate: Sun May 4 09:06:08 2025 -0400

    Normalize local variable and parameter naming
    
    Javadoc
---
 .../apache/commons/fileupload/FileUploadBase.java  | 34 ++++++++--------
 .../fileupload/InvalidFileNameException.java       | 10 ++---
 .../apache/commons/fileupload/MultipartStream.java | 47 ++++++++--------------
 .../commons/fileupload/ProgressListener.java       |  8 ++--
 .../apache/commons/fileupload/FileUploadTest.java  | 11 +++--
 .../commons/fileupload/MockHttpServletRequest.java |  4 +-
 .../commons/fileupload/ProgressListenerTest.java   | 30 +++++++-------
 .../apache/commons/fileupload/StreamingTest.java   | 38 +++++++----------
 8 files changed, 80 insertions(+), 102 deletions(-)

diff --git a/src/main/java/org/apache/commons/fileupload/FileUploadBase.java 
b/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
index 213aa665..db05919a 100644
--- a/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
+++ b/src/main/java/org/apache/commons/fileupload/FileUploadBase.java
@@ -135,11 +135,11 @@ public abstract class FileUploadBase {
                 if (fileSizeMax != -1) {
                     istream = new LimitedInputStream(istream, fileSizeMax) {
                         @Override
-                        protected void raiseError(final long pSizeMax, final 
long pCount) throws IOException {
+                        protected void raiseError(final long sizeMax, final 
long count) throws IOException {
                             itemStream.close(true);
                             final FileSizeLimitExceededException e = new 
FileSizeLimitExceededException(
-                                    format("The field %s exceeds its maximum 
permitted size of %s bytes.", fieldName, Long.valueOf(pSizeMax)), pCount,
-                                    pSizeMax);
+                                    format("The field %s exceeds its maximum 
permitted size of %s bytes.", fieldName, Long.valueOf(sizeMax)), count,
+                                    sizeMax);
                             e.setFieldName(fieldName);
                             e.setFileName(name);
                             throw new FileUploadIOException(e);
@@ -1007,17 +1007,17 @@ public abstract class FileUploadBase {
     /**
      * Returns the field name, which is given by the content-disposition
      * header.
-     * @param pContentDisposition The content-dispositions header value.
-     * @return The field jake
+     * @param contentDisposition The content-dispositions header value.
+     * @return The field name.
      */
-    private String getFieldName(final String pContentDisposition) {
+    private String getFieldName(final String contentDisposition) {
         String fieldName = null;
-        if (pContentDisposition != null
-                && 
pContentDisposition.toLowerCase(Locale.ROOT).startsWith(FORM_DATA)) {
+        if (contentDisposition != null
+                && 
contentDisposition.toLowerCase(Locale.ROOT).startsWith(FORM_DATA)) {
             final ParameterParser parser = new ParameterParser();
             parser.setLowerCaseNames(true);
             // Parameter parser can handle null input
-            final Map<String, String> params = 
parser.parse(pContentDisposition, ';');
+            final Map<String, String> params = 
parser.parse(contentDisposition, ';');
             fieldName = params.get("name");
             if (fieldName != null) {
                 fieldName = fieldName.trim();
@@ -1068,18 +1068,18 @@ public abstract class FileUploadBase {
 
     /**
      * Returns the given content-disposition headers file name.
-     * @param pContentDisposition The content-disposition headers value.
+     * @param contentDisposition The content-disposition headers value.
      * @return The file name
      */
-    private String getFileName(final String pContentDisposition) {
+    private String getFileName(final String contentDisposition) {
         String fileName = null;
-        if (pContentDisposition != null) {
-            final String cdl = pContentDisposition.toLowerCase(Locale.ROOT);
+        if (contentDisposition != null) {
+            final String cdl = contentDisposition.toLowerCase(Locale.ROOT);
             if (cdl.startsWith(FORM_DATA) || cdl.startsWith(ATTACHMENT)) {
                 final ParameterParser parser = new ParameterParser();
                 parser.setLowerCaseNames(true);
                 // Parameter parser can handle null input
-                final Map<String, String> params = 
parser.parse(pContentDisposition, ';');
+                final Map<String, String> params = 
parser.parse(contentDisposition, ';');
                 if (params.containsKey("filename")) {
                     fileName = params.get("filename");
                     if (fileName != null) {
@@ -1454,10 +1454,10 @@ public abstract class FileUploadBase {
     /**
      * Sets the progress listener.
      *
-     * @param pListener The progress listener, if any. Defaults to null.
+     * @param listener The progress listener, if any. Defaults to null.
      */
-    public void setProgressListener(final ProgressListener pListener) {
-        listener = pListener;
+    public void setProgressListener(final ProgressListener listener) {
+        this.listener = listener;
     }
 
     /**
diff --git 
a/src/main/java/org/apache/commons/fileupload/InvalidFileNameException.java 
b/src/main/java/org/apache/commons/fileupload/InvalidFileNameException.java
index 4dc1ffdf..997e4263 100644
--- a/src/main/java/org/apache/commons/fileupload/InvalidFileNameException.java
+++ b/src/main/java/org/apache/commons/fileupload/InvalidFileNameException.java
@@ -42,12 +42,12 @@ public class InvalidFileNameException extends 
RuntimeException {
     /**
      * Creates a new instance.
      *
-     * @param pName The file name causing the exception.
-     * @param pMessage A human readable error message.
+     * @param name The file name causing the exception.
+     * @param message A human readable error message.
      */
-    public InvalidFileNameException(final String pName, final String pMessage) 
{
-        super(pMessage);
-        name = pName;
+    public InvalidFileNameException(final String name, final String message) {
+        super(message);
+        this.name = name;
     }
 
     /**
diff --git a/src/main/java/org/apache/commons/fileupload/MultipartStream.java 
b/src/main/java/org/apache/commons/fileupload/MultipartStream.java
index 84eea9c7..d88fb04a 100644
--- a/src/main/java/org/apache/commons/fileupload/MultipartStream.java
+++ b/src/main/java/org/apache/commons/fileupload/MultipartStream.java
@@ -420,24 +420,24 @@ public class MultipartStream {
          * Creates a new instance with the given listener
          * and content length.
          *
-         * @param pListener The listener to invoke.
-         * @param pContentLength The expected content length.
+         * @param listener The listener to invoke.
+         * @param contentLength The expected content length.
          */
-        ProgressNotifier(final ProgressListener pListener, final long 
pContentLength) {
-            listener = pListener;
-            contentLength = pContentLength;
+        ProgressNotifier(final ProgressListener listener, final long 
contentLength) {
+            this.listener = listener;
+            this.contentLength = contentLength;
         }
 
         /**
          * Called to indicate that bytes have been read.
          *
-         * @param pBytes Number of bytes, which have been read.
+         * @param count Number of bytes, which have been read.
          */
-        void noteBytesRead(final int pBytes) {
+        void noteBytesRead(final int count) {
             /* Indicates, that the given number of bytes have been read from
              * the input stream.
              */
-            bytesRead += pBytes;
+            bytesRead += count;
             notifyListener();
         }
 
@@ -650,17 +650,13 @@ public class MultipartStream {
      * @param boundary The token used for dividing the stream into
      *                 {@code encapsulations}.
      * @param bufSize  The size of the buffer to be used, in bytes.
-     * @param pNotifier The notifier, which is used for calling the
+     * @param notifier The notifier, which is used for calling the
      *                  progress listener, if any.
      *
      * @throws IllegalArgumentException If the buffer size is too small
      * @since 1.3.1
      */
-    public MultipartStream(final InputStream input,
-            final byte[] boundary,
-            final int bufSize,
-            final ProgressNotifier pNotifier) {
-
+    public MultipartStream(final InputStream input, final byte[] boundary, 
final int bufSize, final ProgressNotifier notifier) {
         if (boundary == null) {
             throw new IllegalArgumentException("boundary may not be null");
         }
@@ -668,25 +664,18 @@ public class MultipartStream {
         // body-data tokens.
         this.boundaryLength = boundary.length + BOUNDARY_PREFIX.length;
         if (bufSize < this.boundaryLength + 1) {
-            throw new IllegalArgumentException(
-                    "The buffer size specified for the MultipartStream is too 
small");
+            throw new IllegalArgumentException("The buffer size specified for 
the MultipartStream is too small");
         }
-
         this.input = input;
         this.bufSize = Math.max(bufSize, boundaryLength * 2);
         this.buffer = new byte[this.bufSize];
-        this.notifier = pNotifier;
-
+        this.notifier = notifier;
         this.boundary = new byte[this.boundaryLength];
         this.boundaryTable = new int[this.boundaryLength + 1];
         this.keepRegion = this.boundary.length;
-
-        System.arraycopy(BOUNDARY_PREFIX, 0, this.boundary, 0,
-                BOUNDARY_PREFIX.length);
-        System.arraycopy(boundary, 0, this.boundary, BOUNDARY_PREFIX.length,
-                boundary.length);
+        System.arraycopy(BOUNDARY_PREFIX, 0, this.boundary, 0, 
BOUNDARY_PREFIX.length);
+        System.arraycopy(boundary, 0, this.boundary, BOUNDARY_PREFIX.length, 
boundary.length);
         computeBoundaryTable();
-
         head = 0;
         tail = 0;
     }
@@ -697,15 +686,13 @@ public class MultipartStream {
      * @param input    The {@code InputStream} to serve as a data source.
      * @param boundary The token used for dividing the stream into
      *                 {@code encapsulations}.
-     * @param pNotifier An object for calling the progress listener, if any.
+     * @param notifier An object for calling the progress listener, if any.
      *
      *
      * @see #MultipartStream(InputStream, byte[], int, ProgressNotifier)
      */
-    MultipartStream(final InputStream input,
-            final byte[] boundary,
-            final ProgressNotifier pNotifier) {
-        this(input, boundary, DEFAULT_BUFSIZE, pNotifier);
+    MultipartStream(final InputStream input, final byte[] boundary, final 
ProgressNotifier notifier) {
+        this(input, boundary, DEFAULT_BUFSIZE, notifier);
     }
 
     /**
diff --git a/src/main/java/org/apache/commons/fileupload/ProgressListener.java 
b/src/main/java/org/apache/commons/fileupload/ProgressListener.java
index 5a869ef5..a558b833 100644
--- a/src/main/java/org/apache/commons/fileupload/ProgressListener.java
+++ b/src/main/java/org/apache/commons/fileupload/ProgressListener.java
@@ -25,13 +25,13 @@ public interface ProgressListener {
     /**
      * Updates the listeners status information.
      *
-     * @param pBytesRead The total number of bytes, which have been read
+     * @param bytesRead The total number of bytes, which have been read
      *   so far.
-     * @param pContentLength The total number of bytes, which are being
+     * @param contentLength The total number of bytes, which are being
      *   read. May be -1, if this number is unknown.
-     * @param pItems The number of the field, which is currently being
+     * @param items The number of the field, which is currently being
      *   read. (0 = no item so far, 1 = first item is being read, ...)
      */
-    void update(long pBytesRead, long pContentLength, int pItems);
+    void update(long bytesRead, long contentLength, int items);
 
 }
diff --git a/src/test/java/org/apache/commons/fileupload/FileUploadTest.java 
b/src/test/java/org/apache/commons/fileupload/FileUploadTest.java
index 8c801d44..17d3024a 100644
--- a/src/test/java/org/apache/commons/fileupload/FileUploadTest.java
+++ b/src/test/java/org/apache/commons/fileupload/FileUploadTest.java
@@ -60,12 +60,11 @@ public class FileUploadTest {
     @Parameter
     public FileUpload upload;
 
-    private void assertHeaders(final String[] pHeaderNames, final String[] 
pHeaderValues,
-            final FileItem pItem, final int pIndex) {
-        for (int i = 0; i < pHeaderNames.length; i++) {
-            final String value = pItem.getHeaders().getHeader(pHeaderNames[i]);
-            if (i == pIndex) {
-                assertEquals(pHeaderValues[i], value);
+    private void assertHeaders(final String[] headerNames, final String[] 
headerValues, final FileItem item, final int index) {
+        for (int i = 0; i < headerNames.length; i++) {
+            final String value = item.getHeaders().getHeader(headerNames[i]);
+            if (i == index) {
+                assertEquals(headerValues[i], value);
             } else {
                 assertNull(value);
             }
diff --git 
a/src/test/java/org/apache/commons/fileupload/MockHttpServletRequest.java 
b/src/test/java/org/apache/commons/fileupload/MockHttpServletRequest.java
index 08484f67..dd29db62 100644
--- a/src/test/java/org/apache/commons/fileupload/MockHttpServletRequest.java
+++ b/src/test/java/org/apache/commons/fileupload/MockHttpServletRequest.java
@@ -44,8 +44,8 @@ public class MockHttpServletRequest implements 
HttpServletRequest {
          * Creates a new instance, which returns the given
          * streams data.
          */
-        public MyServletInputStream(final InputStream pStream, final int 
readLimit) {
-            in = pStream;
+        public MyServletInputStream(final InputStream in, final int readLimit) 
{
+            this.in = in;
             this.readLimit = readLimit;
         }
 
diff --git 
a/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java 
b/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java
index ce9d7f72..6aac067f 100644
--- a/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java
+++ b/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java
@@ -42,9 +42,9 @@ public class ProgressListenerTest {
 
         private Integer items;
 
-        ProgressListenerImpl(final long pContentLength, final int pItems) {
-            expectedContentLength = pContentLength;
-            expectedItems = pItems;
+        ProgressListenerImpl(final long expectedContentLength, final int 
expectedItems) {
+            this.expectedContentLength = expectedContentLength;
+            this.expectedItems = expectedItems;
         }
 
         void checkFinished(){
@@ -53,25 +53,25 @@ public class ProgressListenerTest {
         }
 
         @Override
-        public void update(final long pBytesRead, final long pContentLength, 
final int pItems) {
-            assertTrue(pBytesRead >= 0  &&  pBytesRead <= 
expectedContentLength);
-            assertTrue(pContentLength == -1  ||  pContentLength == 
expectedContentLength);
-            assertTrue(pItems >= 0  &&  pItems <= expectedItems);
-
-            assertTrue(bytesRead == null  ||  pBytesRead >= 
bytesRead.longValue());
-            bytesRead = Long.valueOf(pBytesRead);
-            assertTrue(items == null  ||  pItems >= items.intValue());
-            items = Integer.valueOf(pItems);
+        public void update(final long actualBytesRead, final long 
actualContentLength, final int actualItems) {
+            assertTrue(actualBytesRead >= 0  &&  actualBytesRead <= 
expectedContentLength);
+            assertTrue(actualContentLength == -1  ||  actualContentLength == 
expectedContentLength);
+            assertTrue(actualItems >= 0  &&  actualItems <= expectedItems);
+
+            assertTrue(this.bytesRead == null  ||  actualBytesRead >= 
this.bytesRead.longValue());
+            this.bytesRead = Long.valueOf(actualBytesRead);
+            assertTrue(items == null  ||  actualItems >= items.intValue());
+            this.items = Integer.valueOf(actualItems);
         }
 
     }
 
-    private void runTest(final int NUM_ITEMS, final long pContentLength, final 
MockHttpServletRequest request) throws FileUploadException, IOException {
+    private void runTest(final int numItems, final long contentLength, final 
MockHttpServletRequest request) throws FileUploadException, IOException {
         final ServletFileUpload upload = new ServletFileUpload();
-        final ProgressListenerImpl listener = new 
ProgressListenerImpl(pContentLength, NUM_ITEMS);
+        final ProgressListenerImpl listener = new 
ProgressListenerImpl(contentLength, numItems);
         upload.setProgressListener(listener);
         final FileItemIterator iter = upload.getItemIterator(request);
-        for (int i = 0;  i < NUM_ITEMS;  i++) {
+        for (int i = 0;  i < numItems;  i++) {
             final FileItemStream stream = iter.next();
             try (InputStream istream = stream.openStream()) {
                 for (int j = 0; j < 16384 + i; j++) {
diff --git a/src/test/java/org/apache/commons/fileupload/StreamingTest.java 
b/src/test/java/org/apache/commons/fileupload/StreamingTest.java
index a3458296..3a78d131 100644
--- a/src/test/java/org/apache/commons/fileupload/StreamingTest.java
+++ b/src/test/java/org/apache/commons/fileupload/StreamingTest.java
@@ -46,9 +46,9 @@ public class StreamingTest {
         return "-----1234--\r\n";
     }
 
-    private String getHeader(final String pField) {
+    private String getHeader(final String fieldName) {
         return "-----1234\r\n"
-            + "Content-Disposition: form-data; name=\"" + pField + "\"\r\n"
+            + "Content-Disposition: form-data; name=\"" + fieldName + "\"\r\n"
             + "\r\n";
 
     }
@@ -105,27 +105,19 @@ public class StreamingTest {
         return parseUpload(new ByteArrayInputStream(bytes), bytes.length);
     }
 
-    private List<FileItem> parseUpload(final InputStream pStream, final int 
pLength)
-            throws FileUploadException {
+    private List<FileItem> parseUpload(final InputStream in, final int length) 
throws FileUploadException {
         final String contentType = "multipart/form-data; boundary=---1234";
-
         final FileUploadBase upload = new ServletFileUpload();
         upload.setFileItemFactory(new DiskFileItemFactory());
-        final HttpServletRequest request = new MockHttpServletRequest(pStream,
-                pLength, contentType);
-
+        final HttpServletRequest request = new MockHttpServletRequest(in, 
length, contentType);
         return upload.parseRequest(new ServletRequestContext(request));
     }
 
-    private FileItemIterator parseUpload(final int pLength, final InputStream 
pStream)
-            throws FileUploadException, IOException {
+    private FileItemIterator parseUpload(final int length, final InputStream 
in) throws FileUploadException, IOException {
         final String contentType = "multipart/form-data; boundary=---1234";
-
         final FileUploadBase upload = new ServletFileUpload();
         upload.setFileItemFactory(new DiskFileItemFactory());
-        final HttpServletRequest request = new MockHttpServletRequest(pStream,
-                pLength, contentType);
-
+        final HttpServletRequest request = new MockHttpServletRequest(in, 
length, contentType);
         return upload.getItemIterator(new ServletRequestContext(request));
     }
 
@@ -251,11 +243,12 @@ public class StreamingTest {
      * Tests, whether an IOException is properly delegated.
      */
     @Test
-    public void testIOException()
-            throws IOException {
+    public void testIOException() throws IOException {
         final byte[] request = newRequest();
-        final InputStream stream = new FilterInputStream(new 
ByteArrayInputStream(request)){
+        final InputStream stream = new FilterInputStream(new 
ByteArrayInputStream(request)) {
+
             private int num;
+
             @Override
             public int read() throws IOException {
                 if (++num > 123) {
@@ -263,17 +256,17 @@ public class StreamingTest {
                 }
                 return super.read();
             }
+
             @Override
-            public int read(final byte[] pB, final int pOff, final int pLen)
-                    throws IOException {
-                for (int i = 0;  i < pLen;  i++) {
+            public int read(final byte[] buffer, final int offset, final int 
length) throws IOException {
+                for (int i = 0; i < length; i++) {
                     final int res = read();
                     if (res == -1) {
                         return i == 0 ? -1 : i;
                     }
-                    pB[pOff+i] = (byte) res;
+                    buffer[offset + i] = (byte) res;
                 }
-                return pLen;
+                return length;
             }
         };
         try {
@@ -284,5 +277,4 @@ public class StreamingTest {
             assertEquals("123", e.getCause().getMessage());
         }
     }
-
 }

Reply via email to