This is an automated email from the ASF dual-hosted git repository. jochen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-fileupload.git
The following commit(s) were added to refs/heads/master by this push: new 13ecf90 Fix checkstyle warnings new a9d7ca9 Merge pull request #93 from arturobernalg/feature/solve_checkstyle 13ecf90 is described below commit 13ecf9082640032f7e96e26655f2aca063544113 Author: Arturo Bernal <arturobern...@gmail.com> AuthorDate: Sun May 23 15:13:10 2021 +0200 Fix checkstyle warnings --- .../fileupload2/impl/FileItemIteratorImpl.java | 17 +++++++++- .../fileupload2/impl/FileItemStreamImpl.java | 7 +++- .../ParseException.java => impl/package-info.java} | 21 ++---------- .../fileupload2/util/mime/Base64Decoder.java | 2 +- .../fileupload2/util/mime/ParseException.java | 2 +- .../fileupload2/util/mime/RFC2231Utility.java | 38 +++++++++++++++++----- 6 files changed, 55 insertions(+), 32 deletions(-) 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 6143270..c320f02 100644 --- a/src/main/java/org/apache/commons/fileupload2/impl/FileItemIteratorImpl.java +++ b/src/main/java/org/apache/commons/fileupload2/impl/FileItemIteratorImpl.java @@ -44,9 +44,24 @@ import org.apache.commons.io.IOUtils; * {@link FileUploadBase#getItemIterator(RequestContext)}. */ public class FileItemIteratorImpl implements FileItemIterator { + /** + * The file uploads processing utility. + * @see FileUploadBase + */ private final FileUploadBase fileUploadBase; + /** + * The request context. + * @see RequestContext + */ private final RequestContext ctx; - private long sizeMax, fileSizeMax; + /** + * The maximum allowed size of a complete request. + */ + private long sizeMax; + /** + * The maximum allowed size of a single uploaded file. + */ + private long fileSizeMax; @Override diff --git a/src/main/java/org/apache/commons/fileupload2/impl/FileItemStreamImpl.java b/src/main/java/org/apache/commons/fileupload2/impl/FileItemStreamImpl.java index 7a25d55..e3a9b25 100644 --- a/src/main/java/org/apache/commons/fileupload2/impl/FileItemStreamImpl.java +++ b/src/main/java/org/apache/commons/fileupload2/impl/FileItemStreamImpl.java @@ -35,6 +35,11 @@ import org.apache.commons.fileupload2.util.Streams; * Default implementation of {@link FileItemStream}. */ public class FileItemStreamImpl implements FileItemStream { + /** + * The File Item iterator implementation. + * + * @see FileItemIteratorImpl + */ private final FileItemIteratorImpl fileItemIteratorImpl; /** @@ -50,7 +55,7 @@ public class FileItemStreamImpl implements FileItemStream { /** * The file items file name. */ - final String name; + private final String name; /** * Whether the file item is a form field. diff --git a/src/main/java/org/apache/commons/fileupload2/util/mime/ParseException.java b/src/main/java/org/apache/commons/fileupload2/impl/package-info.java similarity index 63% copy from src/main/java/org/apache/commons/fileupload2/util/mime/ParseException.java copy to src/main/java/org/apache/commons/fileupload2/impl/package-info.java index 38f3d91..93c87ac 100644 --- a/src/main/java/org/apache/commons/fileupload2/util/mime/ParseException.java +++ b/src/main/java/org/apache/commons/fileupload2/impl/package-info.java @@ -14,25 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.commons.fileupload2.util.mime; /** - * @since 1.3 + * Implementations and exceptions utils. */ -final class ParseException extends Exception { - - /** - * The UID to use when serializing this instance. - */ - private static final long serialVersionUID = 5355281266579392077L; - - /** - * Constructs a new exception with the specified detail message. - * - * @param message the detail message. - */ - public ParseException(final String message) { - super(message); - } - -} +package org.apache.commons.fileupload2.impl; diff --git a/src/main/java/org/apache/commons/fileupload2/util/mime/Base64Decoder.java b/src/main/java/org/apache/commons/fileupload2/util/mime/Base64Decoder.java index 231df63..9b32d2d 100644 --- a/src/main/java/org/apache/commons/fileupload2/util/mime/Base64Decoder.java +++ b/src/main/java/org/apache/commons/fileupload2/util/mime/Base64Decoder.java @@ -104,7 +104,7 @@ final class Base64Decoder { */ public static int decode(final byte[] data, final OutputStream out) throws IOException { int outLen = 0; - final byte[ ] cache = new byte[INPUT_BYTES_PER_CHUNK]; + final byte[] cache = new byte[INPUT_BYTES_PER_CHUNK]; int cachedBytes = 0; for (final byte b : data) { diff --git a/src/main/java/org/apache/commons/fileupload2/util/mime/ParseException.java b/src/main/java/org/apache/commons/fileupload2/util/mime/ParseException.java index 38f3d91..7981ea4 100644 --- a/src/main/java/org/apache/commons/fileupload2/util/mime/ParseException.java +++ b/src/main/java/org/apache/commons/fileupload2/util/mime/ParseException.java @@ -31,7 +31,7 @@ final class ParseException extends Exception { * * @param message the detail message. */ - public ParseException(final String message) { + ParseException(final String message) { super(message); } diff --git a/src/main/java/org/apache/commons/fileupload2/util/mime/RFC2231Utility.java b/src/main/java/org/apache/commons/fileupload2/util/mime/RFC2231Utility.java index 18d0609..fbdea2d 100644 --- a/src/main/java/org/apache/commons/fileupload2/util/mime/RFC2231Utility.java +++ b/src/main/java/org/apache/commons/fileupload2/util/mime/RFC2231Utility.java @@ -31,10 +31,22 @@ import java.io.UnsupportedEncodingException; * @see <a href="https://tools.ietf.org/html/rfc5987">RFC 5987</a> */ public final class RFC2231Utility { - + /** + * The Hexadecimal values char array. + */ private static final char[] HEX_DIGITS = "0123456789ABCDEF".toCharArray(); - - private static final byte[] HEX_DECODE = new byte[0x80]; + /** + * The Hexadecimal representation of 127. + */ + private static final byte MASK = 0x7f; + /** + * The Hexadecimal representation of 128. + */ + private static final int MASK_128 = 0x80; + /** + * The Hexadecimal decode value. + */ + private static final byte[] HEX_DECODE = new byte[MASK_128]; // create a ASCII decoded array of Hexadecimal values static { @@ -45,8 +57,15 @@ public final class RFC2231Utility { } /** + * Private constructor so that no instances can be created. This class + * contains only static utility methods. + */ + private RFC2231Utility() { + } + + /** * Checks if Asterisk (*) at the end of parameter name to indicate, - * if it has charset and language information to decode the value + * if it has charset and language information to decode the value. * @param paramName The parameter, which is being checked. * @return {@code true}, if encoded as per RFC 2231, {@code false} otherwise */ @@ -59,7 +78,7 @@ public final class RFC2231Utility { /** * If {@code paramName} has Asterisk (*) at the end, it will be stripped off, - * else the passed value will be returned + * else the passed value will be returned. * @param paramName The parameter, which is being inspected. * @return stripped {@code paramName} of Asterisk (*), if RFC2231 encoded */ @@ -106,11 +125,12 @@ public final class RFC2231Utility { } /** - * Convert {@code text} to their corresponding Hex value + * Convert {@code text} to their corresponding Hex value. * @param text - ASCII text input * @return Byte array of characters decoded from ASCII table */ private static byte[] fromHex(final String text) { + final int shift = 4; final ByteArrayOutputStream out = new ByteArrayOutputStream(text.length()); for (int i = 0; i < text.length();) { final char c = text.charAt(i++); @@ -118,9 +138,9 @@ public final class RFC2231Utility { if (i > text.length() - 2) { break; // unterminated sequence } - final byte b1 = HEX_DECODE[text.charAt(i++) & 0x7f]; - final byte b2 = HEX_DECODE[text.charAt(i++) & 0x7f]; - out.write((b1 << 4) | b2); + final byte b1 = HEX_DECODE[text.charAt(i++) & MASK]; + final byte b2 = HEX_DECODE[text.charAt(i++) & MASK]; + out.write((b1 << shift) | b2); } else { out.write((byte) c); }