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 8d546d9b9e27131b1cedc1e755b21e4022ca9d8e Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Sun May 4 08:30:47 2025 -0400 Normalize local variable and parameter naming Javadoc --- .../apache/commons/fileupload/FileUploadBase.java | 66 +++++++++++----------- .../apache/commons/fileupload/MultipartStream.java | 6 +- .../commons/fileupload/disk/DiskFileItem.java | 6 +- .../fileupload/disk/DiskFileItemFactory.java | 21 +++---- .../fileupload/servlet/FileCleanerCleanup.java | 17 +++--- .../fileupload/util/LimitedInputStream.java | 15 ++--- .../apache/commons/fileupload/util/Streams.java | 4 +- 7 files changed, 67 insertions(+), 68 deletions(-) diff --git a/src/main/java/org/apache/commons/fileupload/FileUploadBase.java b/src/main/java/org/apache/commons/fileupload/FileUploadBase.java index 118b6d6d..e1277b94 100644 --- a/src/main/java/org/apache/commons/fileupload/FileUploadBase.java +++ b/src/main/java/org/apache/commons/fileupload/FileUploadBase.java @@ -106,27 +106,27 @@ public abstract class FileUploadBase { /** * Creates a new instance. * - * @param pName The items file name, or null. - * @param pFieldName The items field name. - * @param pContentType The items content type, or null. - * @param pFormField Whether the item is a form field. - * @param pContentLength The items content length, if known, or -1 + * @param name The items file name, or null. + * @param fieldName The items field name. + * @param contentType The items content type, or null. + * @param formField Whether the item is a form field. + * @param contentLength The items content length, if known, or -1 * @throws IOException Creating the file item failed. */ - FileItemStreamImpl(final String pName, final String pFieldName, - final String pContentType, final boolean pFormField, - final long pContentLength) throws IOException { - name = pName; - fieldName = pFieldName; - contentType = pContentType; - formField = pFormField; + FileItemStreamImpl(final String name, final String fieldName, + final String contentType, final boolean formField, + final long contentLength) throws IOException { + this.name = name; + this.fieldName = fieldName; + this.contentType = contentType; + this.formField = formField; // Check if limit is already exceeded - if (fileSizeMax != -1 && pContentLength != -1 && pContentLength > fileSizeMax) { + if (fileSizeMax != -1 && contentLength != -1 && contentLength > fileSizeMax) { final FileSizeLimitExceededException e = new FileSizeLimitExceededException( - format("The field %s exceeds its maximum permitted size of %s bytes.", fieldName, Long.valueOf(fileSizeMax)), pContentLength, + format("The field %s exceeds its maximum permitted size of %s bytes.", fieldName, Long.valueOf(fileSizeMax)), contentLength, fileSizeMax); - e.setFileName(pName); - e.setFieldName(pFieldName); + e.setFileName(name); + e.setFieldName(fieldName); throw new FileUploadIOException(e); } // OK to construct stream now @@ -235,11 +235,11 @@ public abstract class FileUploadBase { /** * Sets the file item headers. * - * @param pHeaders The items header object + * @param headers The items header object */ @Override - public void setHeaders(final FileItemHeaders pHeaders) { - headers = pHeaders; + public void setHeaders(final FileItemHeaders headers) { + this.headers = headers; } } @@ -331,12 +331,12 @@ public abstract class FileUploadBase { // this is eventually closed in MultipartStream processing input = new LimitedInputStream(ctx.getInputStream(), sizeMax) { @Override - protected void raiseError(final long pSizeMax, final long pCount) + protected void raiseError(final long sizeMax, final long count) throws IOException { final FileUploadException ex = new SizeLimitExceededException( format("the request was rejected because its size (%s) exceeds the configured maximum (%s)", - Long.valueOf(pCount), Long.valueOf(pSizeMax)), - pCount, pSizeMax); + Long.valueOf(count), Long.valueOf(sizeMax)), + count, sizeMax); throw new FileUploadIOException(ex); } }; @@ -453,9 +453,9 @@ public abstract class FileUploadBase { } } - private long getContentLength(final FileItemHeaders pHeaders) { + private long getContentLength(final FileItemHeaders headers) { try { - return Long.parseLong(pHeaders.getHeader(CONTENT_LENGTH)); + return Long.parseLong(headers.getHeader(CONTENT_LENGTH)); } catch (final Exception e) { return -1; } @@ -567,21 +567,21 @@ public abstract class FileUploadBase { * Sets the field name of the item, which caused the * exception. * - * @param pFieldName the field name of the item, + * @param fieldName the field name of the item, * which caused the exception. */ - public void setFieldName(final String pFieldName) { - fieldName = pFieldName; + public void setFieldName(final String fieldName) { + this.fieldName = fieldName; } /** * Sets the file name of the item, which caused the * exception. * - * @param pFileName the file name of the item, which caused the exception. + * @param fileName the file name of the item, which caused the exception. */ - public void setFileName(final String pFileName) { - fileName = pFileName; + public void setFileName(final String fileName) { + this.fileName = fileName; } } @@ -608,11 +608,11 @@ public abstract class FileUploadBase { * Creates a {@code FileUploadIOException} with the * given cause. * - * @param pCause The exceptions cause, if any, or null. + * @param cause The exceptions cause, if any, or null. */ - public FileUploadIOException(final FileUploadException pCause) { + public FileUploadIOException(final FileUploadException cause) { // We're not doing super(pCause) cause of 1.3 compatibility. - cause = pCause; + this.cause = cause; } /** diff --git a/src/main/java/org/apache/commons/fileupload/MultipartStream.java b/src/main/java/org/apache/commons/fileupload/MultipartStream.java index 5eddc76d..0750998f 100644 --- a/src/main/java/org/apache/commons/fileupload/MultipartStream.java +++ b/src/main/java/org/apache/commons/fileupload/MultipartStream.java @@ -176,15 +176,15 @@ public class MultipartStream { /** * Closes the input stream. * - * @param pCloseUnderlying Whether to close the underlying stream + * @param closeUnderlying Whether to close the underlying stream * (hard close) * @throws IOException An I/O error occurred. */ - public void close(final boolean pCloseUnderlying) throws IOException { + public void close(final boolean closeUnderlying) throws IOException { if (closed) { return; } - if (pCloseUnderlying) { + if (closeUnderlying) { closed = true; input.close(); } else { diff --git a/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java b/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java index 2367c474..a9866f83 100644 --- a/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java +++ b/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java @@ -543,11 +543,11 @@ public class DiskFileItem implements FileItem { /** * Sets the file item headers. * - * @param pHeaders The file items headers. + * @param headers The file items headers. */ @Override - public void setHeaders(final FileItemHeaders pHeaders) { - headers = pHeaders; + public void setHeaders(final FileItemHeaders headers) { + this.headers = headers; } /** diff --git a/src/main/java/org/apache/commons/fileupload/disk/DiskFileItemFactory.java b/src/main/java/org/apache/commons/fileupload/disk/DiskFileItemFactory.java index ddee9ade..0c46c3b0 100644 --- a/src/main/java/org/apache/commons/fileupload/disk/DiskFileItemFactory.java +++ b/src/main/java/org/apache/commons/fileupload/disk/DiskFileItemFactory.java @@ -148,7 +148,7 @@ public class DiskFileItemFactory implements FileItemFactory { } /** - * Returns the default charset for use when no explicit charset + * Gets the default charset for use when no explicit charset * parameter is provided by the sender. * @return the default charset */ @@ -157,7 +157,7 @@ public class DiskFileItemFactory implements FileItemFactory { } /** - * Returns the tracker, which is responsible for deleting temporary + * Gets the tracker, which is responsible for deleting temporary * files. * * @return An instance of {@link FileCleaningTracker}, or null @@ -168,7 +168,7 @@ public class DiskFileItemFactory implements FileItemFactory { } /** - * Returns the directory used to temporarily store files that are larger + * Gets the directory used to temporarily store files that are larger * than the configured size threshold. * * @return The directory in which temporary files will be located. @@ -180,7 +180,7 @@ public class DiskFileItemFactory implements FileItemFactory { } /** - * Returns the size threshold beyond which files are written directly to + * Gets the size threshold beyond which files are written directly to * disk. The default value is 10240 bytes. * * @return The size threshold, in bytes. @@ -193,22 +193,23 @@ public class DiskFileItemFactory implements FileItemFactory { /** * Sets the default charset for use when no explicit charset * parameter is provided by the sender. - * @param pCharset the default charset + * + * @param charset the default charset */ - public void setDefaultCharset(final String pCharset) { - defaultCharset = pCharset; + public void setDefaultCharset(final String charset) { + this.defaultCharset = charset; } /** * Sets the tracker, which is responsible for deleting temporary * files. * - * @param pTracker An instance of {@link FileCleaningTracker}, + * @param fileCleaningTracker An instance of {@link FileCleaningTracker}, * which will from now on track the created files, or null * (default), to disable tracking. */ - public void setFileCleaningTracker(final FileCleaningTracker pTracker) { - fileCleaningTracker = pTracker; + public void setFileCleaningTracker(final FileCleaningTracker fileCleaningTracker) { + this.fileCleaningTracker = fileCleaningTracker; } /** diff --git a/src/main/java/org/apache/commons/fileupload/servlet/FileCleanerCleanup.java b/src/main/java/org/apache/commons/fileupload/servlet/FileCleanerCleanup.java index f6f8ec72..75be752c 100644 --- a/src/main/java/org/apache/commons/fileupload/servlet/FileCleanerCleanup.java +++ b/src/main/java/org/apache/commons/fileupload/servlet/FileCleanerCleanup.java @@ -40,25 +40,22 @@ public class FileCleanerCleanup implements ServletContextListener { * Returns the instance of {@link FileCleaningTracker}, which is * associated with the given {@link ServletContext}. * - * @param pServletContext The servlet context to query + * @param servletContext The servlet context to query * @return The contexts tracker */ - public static FileCleaningTracker - getFileCleaningTracker(final ServletContext pServletContext) { - return (FileCleaningTracker) - pServletContext.getAttribute(FILE_CLEANING_TRACKER_ATTRIBUTE); + public static FileCleaningTracker getFileCleaningTracker(final ServletContext servletContext) { + return (FileCleaningTracker) servletContext.getAttribute(FILE_CLEANING_TRACKER_ATTRIBUTE); } /** * Sets the instance of {@link FileCleaningTracker}, which is * associated with the given {@link ServletContext}. * - * @param pServletContext The servlet context to modify - * @param pTracker The tracker to set + * @param servletContext The servlet context to modify + * @param tracker The tracker to set */ - public static void setFileCleaningTracker(final ServletContext pServletContext, - final FileCleaningTracker pTracker) { - pServletContext.setAttribute(FILE_CLEANING_TRACKER_ATTRIBUTE, pTracker); + public static void setFileCleaningTracker(final ServletContext servletContext, final FileCleaningTracker tracker) { + servletContext.setAttribute(FILE_CLEANING_TRACKER_ATTRIBUTE, tracker); } /** diff --git a/src/main/java/org/apache/commons/fileupload/util/LimitedInputStream.java b/src/main/java/org/apache/commons/fileupload/util/LimitedInputStream.java index 76d79452..3b8ef35b 100644 --- a/src/main/java/org/apache/commons/fileupload/util/LimitedInputStream.java +++ b/src/main/java/org/apache/commons/fileupload/util/LimitedInputStream.java @@ -45,12 +45,12 @@ public abstract class LimitedInputStream extends FilterInputStream implements Cl * Creates a new instance. * * @param inputStream The input stream, which shall be limited. - * @param pSizeMax The limit; no more than this number of bytes + * @param sizeMax The limit; no more than this number of bytes * shall be returned by the source stream. */ - public LimitedInputStream(final InputStream inputStream, final long pSizeMax) { + public LimitedInputStream(final InputStream inputStream, final long sizeMax) { super(inputStream); - sizeMax = pSizeMax; + this.sizeMax = sizeMax; } /** @@ -95,13 +95,12 @@ public abstract class LimitedInputStream extends FilterInputStream implements Cl * Called to indicate, that the input streams limit has * been exceeded. * - * @param pSizeMax The input streams limit, in bytes. - * @param pCount The actual number of bytes. + * @param sizeMax The input streams limit, in bytes. + * @param count The actual number of bytes. * @throws IOException The called method is expected * to raise an IOException. */ - protected abstract void raiseError(long pSizeMax, long pCount) - throws IOException; + protected abstract void raiseError(long sizeMax, long count) throws IOException; /** * Reads the next byte of data from this input stream. The value @@ -114,6 +113,7 @@ public abstract class LimitedInputStream extends FilterInputStream implements Cl * <p> * This method * simply performs {@code in.read()} and returns the result. + * </p> * * @return the next byte of data, or {@code -1} if the end of the * stream is reached. @@ -138,6 +138,7 @@ public abstract class LimitedInputStream extends FilterInputStream implements Cl * <p> * This method simply performs {@code in.read(b, off, len)} * and returns the result. + * </p> * * @param b the buffer into which the data is read. * @param off The start offset in the destination array diff --git a/src/main/java/org/apache/commons/fileupload/util/Streams.java b/src/main/java/org/apache/commons/fileupload/util/Streams.java index c766951a..b6b2599a 100644 --- a/src/main/java/org/apache/commons/fileupload/util/Streams.java +++ b/src/main/java/org/apache/commons/fileupload/util/Streams.java @@ -82,7 +82,7 @@ public final class Streams { */ public static String checkFileName(final String fileName) { if (fileName != null && fileName.indexOf('\u0000') != -1) { - // pFileName.replace("\u0000", "\\0") + // fileName.replace("\u0000", "\\0") final StringBuilder sb = new StringBuilder(); for (int i = 0; i < fileName.length(); i++) { final char c = fileName.charAt(i); @@ -105,7 +105,7 @@ public final class Streams { * Copies the contents of the given {@link InputStream} * to the given {@link OutputStream}. Shortcut for * <pre> - * copy(pInputStream, pOutputStream, new byte[8192]); + * copy(pInputStream, outputStream, new byte[8192]); * </pre> * * @param inputStream The input stream, which is being read.