You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/04/02 16:04:56 UTC

[commons-fileupload] branch master updated (3ee89c5 -> bc597d6)

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

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


    from 3ee89c5  Fix method name
     new 78ffb0a  Remove noisy inline comments
     new bc597d6  Replace org.apache.commons.fileupload2.util.mime.Base64Decoder with java.util.Base64

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                            |   1 +
 .../org/apache/commons/fileupload2/FileItem.java   |   4 -
 .../org/apache/commons/fileupload2/FileUpload.java |   6 -
 .../apache/commons/fileupload2/FileUploadBase.java |   6 -
 .../commons/fileupload2/MultipartStream.java       |   6 -
 .../commons/fileupload2/disk/DiskFileItem.java     |  16 --
 .../fileupload2/disk/DiskFileItemFactory.java      |  10 --
 .../fileupload2/jaksrvlt/JakSrvltFileUpload.java   |   6 -
 .../jaksrvlt/JakSrvltRequestContext.java           |   6 -
 .../fileupload2/portlet/PortletFileUpload.java     |   6 -
 .../fileupload2/servlet/ServletFileUpload.java     |   2 -
 .../fileupload2/servlet/ServletRequestContext.java |   6 -
 .../fileupload2/util/mime/Base64Decoder.java       | 151 -------------------
 .../commons/fileupload2/util/mime/MimeUtility.java |   3 +-
 .../apache/commons/fileupload2/FileUploadTest.java |   2 -
 .../util/mime/Base64DecoderTestCase.java           | 162 ---------------------
 16 files changed, 3 insertions(+), 390 deletions(-)
 delete mode 100644 src/main/java/org/apache/commons/fileupload2/util/mime/Base64Decoder.java
 delete mode 100644 src/test/java/org/apache/commons/fileupload2/util/mime/Base64DecoderTestCase.java


[commons-fileupload] 01/02: Remove noisy inline comments

Posted by gg...@apache.org.
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 78ffb0a545058aa896db7cb6487032cc76290726
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Apr 2 12:03:38 2023 -0400

    Remove noisy inline comments
---
 .../java/org/apache/commons/fileupload2/FileItem.java    |  4 ----
 .../java/org/apache/commons/fileupload2/FileUpload.java  |  6 ------
 .../org/apache/commons/fileupload2/FileUploadBase.java   |  6 ------
 .../org/apache/commons/fileupload2/MultipartStream.java  |  6 ------
 .../apache/commons/fileupload2/disk/DiskFileItem.java    | 16 ----------------
 .../commons/fileupload2/disk/DiskFileItemFactory.java    | 10 ----------
 .../commons/fileupload2/jaksrvlt/JakSrvltFileUpload.java |  6 ------
 .../fileupload2/jaksrvlt/JakSrvltRequestContext.java     |  6 ------
 .../commons/fileupload2/portlet/PortletFileUpload.java   |  6 ------
 .../commons/fileupload2/servlet/ServletFileUpload.java   |  2 --
 .../fileupload2/servlet/ServletRequestContext.java       |  6 ------
 .../org/apache/commons/fileupload2/FileUploadTest.java   |  2 --
 12 files changed, 76 deletions(-)

diff --git a/src/main/java/org/apache/commons/fileupload2/FileItem.java b/src/main/java/org/apache/commons/fileupload2/FileItem.java
index 49df5c6..a44369e 100644
--- a/src/main/java/org/apache/commons/fileupload2/FileItem.java
+++ b/src/main/java/org/apache/commons/fileupload2/FileItem.java
@@ -47,8 +47,6 @@ import java.io.UnsupportedEncodingException;
  */
 public interface FileItem extends FileItemHeadersSupport {
 
-    // ------------------------------- Methods from javax.activation.DataSource
-
     /**
      * Deletes the underlying storage for a file item, including deleting any
      * associated temporary disk file. Although this storage will be deleted
@@ -76,8 +74,6 @@ public interface FileItem extends FileItemHeadersSupport {
      */
     String getContentType();
 
-    // ------------------------------------------------------- FileItem methods
-
     /**
      * Returns the name of the field in the multipart form corresponding to
      * this file item.
diff --git a/src/main/java/org/apache/commons/fileupload2/FileUpload.java b/src/main/java/org/apache/commons/fileupload2/FileUpload.java
index aee39f9..1c8bf28 100644
--- a/src/main/java/org/apache/commons/fileupload2/FileUpload.java
+++ b/src/main/java/org/apache/commons/fileupload2/FileUpload.java
@@ -33,15 +33,11 @@ package org.apache.commons.fileupload2;
 public class FileUpload
     extends FileUploadBase {
 
-    // ----------------------------------------------------------- Data members
-
     /**
      * The factory to use to create new form items.
      */
     private FileItemFactory fileItemFactory;
 
-    // ----------------------------------------------------------- Constructors
-
     /**
      * Constructs an uninitialized instance of this class.
      *
@@ -65,8 +61,6 @@ public class FileUpload
         this.fileItemFactory = fileItemFactory;
     }
 
-    // ----------------------------------------------------- Property accessors
-
     /**
      * Returns the factory class used when creating file items.
      *
diff --git a/src/main/java/org/apache/commons/fileupload2/FileUploadBase.java b/src/main/java/org/apache/commons/fileupload2/FileUploadBase.java
index 58cb26f..3257ea0 100644
--- a/src/main/java/org/apache/commons/fileupload2/FileUploadBase.java
+++ b/src/main/java/org/apache/commons/fileupload2/FileUploadBase.java
@@ -48,15 +48,11 @@ import org.apache.commons.fileupload2.util.Streams;
  */
 public abstract class FileUploadBase {
 
-    // ---------------------------------------------------------- Class methods
-
     /**
      * HTTP content type header name.
      */
     public static final String CONTENT_TYPE = "Content-type";
 
-    // ----------------------------------------------------- Manifest constants
-
     /**
      * HTTP content disposition header name.
      */
@@ -114,8 +110,6 @@ public abstract class FileUploadBase {
         return contentType.toLowerCase(Locale.ENGLISH).startsWith(MULTIPART);
     }
 
-    // ----------------------------------------------------------- Data members
-
     /**
      * The maximum size permitted for the complete request, as opposed to
      * {@link #fileSizeMax}. A value of -1 indicates no maximum.
diff --git a/src/main/java/org/apache/commons/fileupload2/MultipartStream.java b/src/main/java/org/apache/commons/fileupload2/MultipartStream.java
index fbb2f60..67769e7 100644
--- a/src/main/java/org/apache/commons/fileupload2/MultipartStream.java
+++ b/src/main/java/org/apache/commons/fileupload2/MultipartStream.java
@@ -476,8 +476,6 @@ public class MultipartStream {
      */
     protected static final byte[] HEADER_SEPARATOR = { CR, LF, CR, LF };
 
-    // ----------------------------------------------------------- Data members
-
     /**
      * A byte sequence that that follows a delimiter that will be followed by an encapsulation ({@code CRLF}).
      */
@@ -546,8 +544,6 @@ public class MultipartStream {
      */
     private final byte[] buffer;
 
-    // ----------------------------------------------------------- Constructors
-
     /**
      * The index of first valid character in the buffer. <br>
      * 0 <= head < bufSize
@@ -572,8 +568,6 @@ public class MultipartStream {
 
 
 
-    // --------------------------------------------------------- Public methods
-
     /**
      * <p>
      * Constructs a {@code MultipartStream} with a custom size buffer.
diff --git a/src/main/java/org/apache/commons/fileupload2/disk/DiskFileItem.java b/src/main/java/org/apache/commons/fileupload2/disk/DiskFileItem.java
index 90af239..a8b6c46 100644
--- a/src/main/java/org/apache/commons/fileupload2/disk/DiskFileItem.java
+++ b/src/main/java/org/apache/commons/fileupload2/disk/DiskFileItem.java
@@ -71,8 +71,6 @@ import org.apache.commons.io.output.DeferredFileOutputStream;
 public class DiskFileItem
     implements FileItem {
 
-    // ----------------------------------------------------- Manifest constants
-
     /**
      * Default content charset to be used when no explicit charset
      * parameter is provided by the sender. Media subtypes of the
@@ -81,8 +79,6 @@ public class DiskFileItem
      */
     public static final String DEFAULT_CHARSET = "ISO-8859-1";
 
-    // ----------------------------------------------------------- Data members
-
     /**
      * UID used in unique file name generation.
      */
@@ -171,16 +167,12 @@ public class DiskFileItem
      */
     private FileItemHeaders headers;
 
-    // ----------------------------------------------------------- Constructors
-
     /**
      * Default content charset to be used when no explicit charset
      * parameter is provided by the sender.
      */
     private String defaultCharset = DEFAULT_CHARSET;
 
-    // ------------------------------- Methods from javax.activation.DataSource
-
     /**
      * Constructs a new {@code DiskFileItem} instance.
      *
@@ -269,8 +261,6 @@ public class DiskFileItem
         return params.get("charset");
     }
 
-    // ------------------------------------------------------- FileItem methods
-
     /**
      * Returns the content type passed by the agent or {@code null} if
      * not defined.
@@ -476,8 +466,6 @@ public class DiskFileItem
         return tempFile;
     }
 
-    // --------------------------------------------------------- Public methods
-
     /**
      * Determines whether or not a {@code FileItem} instance represents
      * a simple form field.
@@ -493,8 +481,6 @@ public class DiskFileItem
         return isFormField;
     }
 
-    // ------------------------------------------------------ Protected methods
-
     /**
      * Provides a hint as to whether or not the file contents will be read
      * from memory.
@@ -510,8 +496,6 @@ public class DiskFileItem
         return dfos.isInMemory();
     }
 
-    // -------------------------------------------------------- Private methods
-
     /**
      * Sets the default charset for use when no explicit charset
      * parameter is provided by the sender.
diff --git a/src/main/java/org/apache/commons/fileupload2/disk/DiskFileItemFactory.java b/src/main/java/org/apache/commons/fileupload2/disk/DiskFileItemFactory.java
index 2943f37..1397e94 100644
--- a/src/main/java/org/apache/commons/fileupload2/disk/DiskFileItemFactory.java
+++ b/src/main/java/org/apache/commons/fileupload2/disk/DiskFileItemFactory.java
@@ -69,15 +69,11 @@ import org.apache.commons.io.FileCleaningTracker;
  */
 public class DiskFileItemFactory implements FileItemFactory {
 
-    // ----------------------------------------------------- Manifest constants
-
     /**
      * The default threshold above which uploads will be stored on disk.
      */
     public static final int DEFAULT_SIZE_THRESHOLD = 10240;
 
-    // ----------------------------------------------------- Instance Variables
-
     /**
      * The directory in which uploaded files will be stored, if stored on disk.
      */
@@ -101,8 +97,6 @@ public class DiskFileItemFactory implements FileItemFactory {
      */
     private String defaultCharset = DiskFileItem.DEFAULT_CHARSET;
 
-    // ----------------------------------------------------------- Constructors
-
     /**
      * Constructs an unconfigured instance of this class. The resulting factory
      * may be configured by calling the appropriate setter methods.
@@ -126,8 +120,6 @@ public class DiskFileItemFactory implements FileItemFactory {
         this.repository = repository;
     }
 
-    // ------------------------------------------------------------- Properties
-
     /**
      * Create a new {@link org.apache.commons.fileupload2.disk.DiskFileItem}
      * instance from the supplied parameters and the local factory
@@ -188,8 +180,6 @@ public class DiskFileItemFactory implements FileItemFactory {
         return repository;
     }
 
-    // --------------------------------------------------------- Public Methods
-
     /**
      * Returns the size threshold beyond which files are written directly to
      * disk. The default value is 10240 bytes.
diff --git a/src/main/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltFileUpload.java b/src/main/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltFileUpload.java
index 088918d..1912373 100644
--- a/src/main/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltFileUpload.java
+++ b/src/main/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltFileUpload.java
@@ -50,8 +50,6 @@ public class JakSrvltFileUpload extends FileUpload {
      */
     private static final String POST_METHOD = "POST";
 
-    // ---------------------------------------------------------- Class methods
-
     /**
      * Utility method that determines whether the request contains multipart
      * content.
@@ -69,8 +67,6 @@ public class JakSrvltFileUpload extends FileUpload {
         return FileUploadBase.isMultipartContent(new JakSrvltRequestContext(request));
     }
 
-    // ----------------------------------------------------------- Constructors
-
     /**
      * Constructs an uninitialized instance of this class. A factory must be
      * configured, using {@code setFileItemFactory()}, before attempting
@@ -92,8 +88,6 @@ public class JakSrvltFileUpload extends FileUpload {
         super(fileItemFactory);
     }
 
-    // --------------------------------------------------------- Public methods
-
     /**
      * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>
      * compliant {@code multipart/form-data} stream.
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 cb40ab7..9855c42 100644
--- a/src/main/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltRequestContext.java
+++ b/src/main/java/org/apache/commons/fileupload2/jaksrvlt/JakSrvltRequestContext.java
@@ -34,15 +34,11 @@ import jakarta.servlet.http.HttpServletRequest;
  */
 public class JakSrvltRequestContext implements UploadContext {
 
-    // ----------------------------------------------------- Instance Variables
-
     /**
      * The request for which the context is being provided.
      */
     private final HttpServletRequest request;
 
-    // ----------------------------------------------------------- Constructors
-
     /**
      * Construct a context for this request.
      *
@@ -52,8 +48,6 @@ public class JakSrvltRequestContext implements UploadContext {
         this.request = request;
     }
 
-    // --------------------------------------------------------- Public Methods
-
     /**
      * Retrieve the content length of the request.
      *
diff --git a/src/main/java/org/apache/commons/fileupload2/portlet/PortletFileUpload.java b/src/main/java/org/apache/commons/fileupload2/portlet/PortletFileUpload.java
index c356334..f0f6df4 100644
--- a/src/main/java/org/apache/commons/fileupload2/portlet/PortletFileUpload.java
+++ b/src/main/java/org/apache/commons/fileupload2/portlet/PortletFileUpload.java
@@ -48,8 +48,6 @@ import org.apache.commons.fileupload2.FileUploadException;
  */
 public class PortletFileUpload extends FileUpload {
 
-    // ---------------------------------------------------------- Class methods
-
     /**
      * Utility method that determines whether the request contains multipart
      * content.
@@ -64,8 +62,6 @@ public class PortletFileUpload extends FileUpload {
                 new PortletRequestContext(request));
     }
 
-    // ----------------------------------------------------------- Constructors
-
     /**
      * Constructs an uninitialized instance of this class. A factory must be
      * configured, using {@code setFileItemFactory()}, before attempting
@@ -87,8 +83,6 @@ public class PortletFileUpload extends FileUpload {
         super(fileItemFactory);
     }
 
-    // --------------------------------------------------------- Public methods
-
     /**
      * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>
      * compliant {@code multipart/form-data} stream.
diff --git a/src/main/java/org/apache/commons/fileupload2/servlet/ServletFileUpload.java b/src/main/java/org/apache/commons/fileupload2/servlet/ServletFileUpload.java
index c7fdf57..4e3f061 100644
--- a/src/main/java/org/apache/commons/fileupload2/servlet/ServletFileUpload.java
+++ b/src/main/java/org/apache/commons/fileupload2/servlet/ServletFileUpload.java
@@ -88,8 +88,6 @@ public class ServletFileUpload extends FileUpload {
         super(fileItemFactory);
     }
 
-    // --------------------------------------------------------- Public methods
-
     /**
      * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>
      * compliant {@code multipart/form-data} stream.
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 6066294..a4706c1 100644
--- a/src/main/java/org/apache/commons/fileupload2/servlet/ServletRequestContext.java
+++ b/src/main/java/org/apache/commons/fileupload2/servlet/ServletRequestContext.java
@@ -34,15 +34,11 @@ import org.apache.commons.fileupload2.UploadContext;
  */
 public class ServletRequestContext implements UploadContext {
 
-    // ----------------------------------------------------- Instance Variables
-
     /**
      * The request for which the context is being provided.
      */
     private final HttpServletRequest request;
 
-    // ----------------------------------------------------------- Constructors
-
     /**
      * Construct a context for this request.
      *
@@ -52,8 +48,6 @@ public class ServletRequestContext implements UploadContext {
         this.request = request;
     }
 
-    // --------------------------------------------------------- Public Methods
-
     /**
      * Retrieve the content length of the request.
      *
diff --git a/src/test/java/org/apache/commons/fileupload2/FileUploadTest.java b/src/test/java/org/apache/commons/fileupload2/FileUploadTest.java
index 461e065..3c1310e 100644
--- a/src/test/java/org/apache/commons/fileupload2/FileUploadTest.java
+++ b/src/test/java/org/apache/commons/fileupload2/FileUploadTest.java
@@ -49,8 +49,6 @@ public class FileUploadTest {
         return Util.fileUploadImplementations().stream();
     }
 
-    // --- Test methods common to all implementations of a FileUpload
-
     private void assertHeaders(final String[] pHeaderNames, final String[] pHeaderValues,
             final FileItem pItem, final int pIndex) {
         for (int i = 0; i < pHeaderNames.length; i++) {


[commons-fileupload] 02/02: Replace org.apache.commons.fileupload2.util.mime.Base64Decoder with java.util.Base64

Posted by gg...@apache.org.
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 bc597d653d417a0b872b27458e4f42c89c00c1b7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Apr 2 12:04:51 2023 -0400

    Replace org.apache.commons.fileupload2.util.mime.Base64Decoder with
    java.util.Base64
---
 src/changes/changes.xml                            |   1 +
 .../fileupload2/util/mime/Base64Decoder.java       | 151 -------------------
 .../commons/fileupload2/util/mime/MimeUtility.java |   3 +-
 .../util/mime/Base64DecoderTestCase.java           | 162 ---------------------
 4 files changed, 3 insertions(+), 314 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 1c2cc94..76fd66b 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -71,6 +71,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                        dev="ggregory" type="remove" due-to="Gary Gregory">Remove deprecated FileUploadBase.getFileName(Map).</action>
       <action                        dev="ggregory" type="remove" due-to="Gary Gregory">Remove deprecated FileUploadBase.getHeader(Map, String).</action>
       <action                        dev="ggregory" type="remove" due-to="Gary Gregory">Remove deprecated FileUploadBase.parseHeaders(String).</action>
+      <action                        dev="ggregory" type="remove" due-to="Gary Gregory">Replace org.apache.commons.fileupload2.util.mime.Base64Decoder with java.util.Base64.</action>
       <!-- UPDATE -->
       <action                        dev="ggregory" type="update" due-to="Dependabot, Gary Gregory">Bump actions/cache from 2.1.6 to 3.0.8 #128, #140.</action>
       <action                        dev="ggregory" type="update" due-to="Dependabot, Gary Gregory">Bump actions/checkout from 2.3.4 to 3.0.2 #125.</action>
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
deleted file mode 100644
index 5222e8f..0000000
--- a/src/main/java/org/apache/commons/fileupload2/util/mime/Base64Decoder.java
+++ /dev/null
@@ -1,151 +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.util.mime;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Arrays;
-
-/**
- * @since 1.3
- */
-final class Base64Decoder {
-
-    /**
-     * Decoding table value for invalid bytes.
-     */
-    private static final byte INVALID_BYTE = -1; // must be outside range 0-63
-
-    /**
-     * Decoding table value for padding bytes, so can detect PAD after conversion.
-     */
-    private static final int PAD_BYTE = -2; // must be outside range 0-63
-
-    /**
-     * Mask to treat byte as unsigned integer.
-     */
-    private static final int MASK_BYTE_UNSIGNED = 0xFF;
-
-    /**
-     * Number of bytes per encoded chunk - 4 6bit bytes produce 3 8bit bytes on output.
-     */
-    private static final int INPUT_BYTES_PER_CHUNK = 4;
-
-    /**
-     * Set up the encoding table.
-     */
-    private static final byte[] ENCODING_TABLE = {
-        (byte) 'A', (byte) 'B', (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F', (byte) 'G',
-        (byte) 'H', (byte) 'I', (byte) 'J', (byte) 'K', (byte) 'L', (byte) 'M', (byte) 'N',
-        (byte) 'O', (byte) 'P', (byte) 'Q', (byte) 'R', (byte) 'S', (byte) 'T', (byte) 'U',
-        (byte) 'V', (byte) 'W', (byte) 'X', (byte) 'Y', (byte) 'Z',
-        (byte) 'a', (byte) 'b', (byte) 'c', (byte) 'd', (byte) 'e', (byte) 'f', (byte) 'g',
-        (byte) 'h', (byte) 'i', (byte) 'j', (byte) 'k', (byte) 'l', (byte) 'm', (byte) 'n',
-        (byte) 'o', (byte) 'p', (byte) 'q', (byte) 'r', (byte) 's', (byte) 't', (byte) 'u',
-        (byte) 'v', (byte) 'w', (byte) 'x', (byte) 'y', (byte) 'z',
-        (byte) '0', (byte) '1', (byte) '2', (byte) '3', (byte) '4', (byte) '5', (byte) '6',
-        (byte) '7', (byte) '8', (byte) '9',
-        (byte) '+', (byte) '/'
-    };
-
-    /**
-     * The padding byte.
-     */
-    private static final byte PADDING = (byte) '=';
-
-    /**
-     * Set up the decoding table; this is indexed by a byte converted to an unsigned int,
-     * so must be at least as large as the number of different byte values,
-     * positive and negative and zero.
-     */
-    private static final byte[] DECODING_TABLE = new byte[Byte.MAX_VALUE - Byte.MIN_VALUE + 1];
-
-    static {
-        // Initialize as all invalid characters
-        Arrays.fill(DECODING_TABLE, INVALID_BYTE);
-        // set up valid characters
-        for (int i = 0; i < ENCODING_TABLE.length; i++) {
-            DECODING_TABLE[ENCODING_TABLE[i]] = (byte) i;
-        }
-        // Allow pad byte to be easily detected after conversion
-        DECODING_TABLE[PADDING] = PAD_BYTE;
-    }
-
-    /**
-     * Decode the base 64 encoded byte data writing it to the given output stream,
-     * whitespace characters will be ignored.
-     *
-     * @param data the buffer containing the Base64-encoded data
-     * @param out the output stream to hold the decoded bytes
-     *
-     * @return the number of bytes produced.
-     * @throws IOException thrown when the padding is incorrect or the input is truncated.
-     */
-    public static int decode(final byte[] data, final OutputStream out) throws IOException {
-        int        outLen = 0;
-        final byte[] cache = new byte[INPUT_BYTES_PER_CHUNK];
-        int cachedBytes = 0;
-
-        for (final byte b : data) {
-            final byte d = DECODING_TABLE[MASK_BYTE_UNSIGNED & b];
-            if (d == INVALID_BYTE) {
-                continue; // Ignore invalid bytes
-            }
-            cache[cachedBytes++] = d;
-            if (cachedBytes == INPUT_BYTES_PER_CHUNK) {
-                // CHECKSTYLE IGNORE MagicNumber FOR NEXT 4 LINES
-                final byte b1 = cache[0];
-                final byte b2 = cache[1];
-                final byte b3 = cache[2];
-                final byte b4 = cache[3];
-                if (b1 == PAD_BYTE || b2 == PAD_BYTE) {
-                    throw new IOException("Invalid Base64 input: incorrect padding, first two bytes cannot be padding");
-                }
-                // Convert 4 6-bit bytes to 3 8-bit bytes
-                // CHECKSTYLE IGNORE MagicNumber FOR NEXT 1 LINE
-                out.write((b1 << 2) | (b2 >> 4)); // 6 bits of b1 plus 2 bits of b2
-                outLen++;
-                if (b3 != PAD_BYTE) {
-                    // CHECKSTYLE IGNORE MagicNumber FOR NEXT 1 LINE
-                    out.write((b2 << 4) | (b3 >> 2)); // 4 bits of b2 plus 4 bits of b3
-                    outLen++;
-                    if (b4 != PAD_BYTE) {
-                        // CHECKSTYLE IGNORE MagicNumber FOR NEXT 1 LINE
-                        out.write((b3 << 6) | b4);        // 2 bits of b3 plus 6 bits of b4
-                        outLen++;
-                    }
-                } else if (b4 != PAD_BYTE) { // if byte 3 is pad, byte 4 must be pad too
-                    throw new // line wrap to avoid 120 char limit
-                    IOException("Invalid Base64 input: incorrect padding, 4th byte must be padding if 3rd byte is");
-                }
-                cachedBytes = 0;
-            }
-        }
-        // Check for anything left over
-        if (cachedBytes != 0) {
-            throw new IOException("Invalid Base64 input: truncated");
-        }
-        return outLen;
-    }
-
-    /**
-     * Hidden constructor, this class must not be instantiated.
-     */
-    private Base64Decoder() {
-        // do nothing
-    }
-}
diff --git a/src/main/java/org/apache/commons/fileupload2/util/mime/MimeUtility.java b/src/main/java/org/apache/commons/fileupload2/util/mime/MimeUtility.java
index 9f56fec..9f61f6f 100644
--- a/src/main/java/org/apache/commons/fileupload2/util/mime/MimeUtility.java
+++ b/src/main/java/org/apache/commons/fileupload2/util/mime/MimeUtility.java
@@ -20,6 +20,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.nio.charset.StandardCharsets;
+import java.util.Base64;
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
@@ -230,7 +231,7 @@ public final class MimeUtility {
 
             // Base64 encoded?
             if (encoding.equals(BASE64_ENCODING_MARKER)) {
-                Base64Decoder.decode(encodedData, out);
+                out.write(Base64.getMimeDecoder().decode(encodedData));
             } else if (encoding.equals(QUOTEDPRINTABLE_ENCODING_MARKER)) { // maybe quoted printable.
                 QuotedPrintableDecoder.decode(encodedData, out);
             } else {
diff --git a/src/test/java/org/apache/commons/fileupload2/util/mime/Base64DecoderTestCase.java b/src/test/java/org/apache/commons/fileupload2/util/mime/Base64DecoderTestCase.java
deleted file mode 100644
index ead3263..0000000
--- a/src/test/java/org/apache/commons/fileupload2/util/mime/Base64DecoderTestCase.java
+++ /dev/null
@@ -1,162 +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.util.mime;
-
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-
-import org.junit.jupiter.api.Test;
-
-/**
- * @since 1.3
- */
-public final class Base64DecoderTestCase {
-
-    private static void assertEncoded(final String clearText, final String encoded) throws Exception {
-        final byte[] expected = clearText.getBytes(StandardCharsets.US_ASCII);
-
-        final ByteArrayOutputStream out = new ByteArrayOutputStream(encoded.length());
-        final byte[] encodedData = encoded.getBytes(StandardCharsets.US_ASCII);
-        Base64Decoder.decode(encodedData, out);
-        final byte[] actual = out.toByteArray();
-
-        assertArrayEquals(expected, actual);
-    }
-
-    private static void assertIOException(final String messageText, final String encoded) {
-        final ByteArrayOutputStream out = new ByteArrayOutputStream(encoded.length());
-        final byte[] encodedData = encoded.getBytes(StandardCharsets.US_ASCII);
-        try {
-            Base64Decoder.decode(encodedData, out);
-            fail("Expected IOException");
-        } catch (final IOException e) {
-            final String em = e.getMessage();
-            assertTrue(em.contains(messageText), "Expected to find " + messageText + " in '" + em + "'");
-        }
-    }
-
-    // This input causes java.lang.ArrayIndexOutOfBoundsException: 1
-    // in the Java 6 method DatatypeConverter.parseBase64Binary(String)
-    // currently reported as truncated (the last chunk consists just of '=')
-    @Test
-    public void badLength() throws Exception {
-        assertIOException("truncated", "Zm8==");
-    }
-
-    @Test
-    public void badPadding() throws Exception {
-        assertIOException("incorrect padding, 4th byte", "Zg=a");
-    }
-
-    @Test
-    public void badPaddingLeading1() throws Exception {
-        assertIOException("incorrect padding, first two bytes cannot be padding", "=A==");
-    }
-
-    @Test
-    public void badPaddingLeading2() throws Exception {
-        assertIOException("incorrect padding, first two bytes cannot be padding", "====");
-    }
-
-    // If there are valid trailing Base64 chars, complain
-    @Test
-    public void decodeTrailing1() throws Exception {
-        assertIOException("truncated", "Zm9vYmFy1");
-    }
-
-    // If there are valid trailing Base64 chars, complain
-    @Test
-    public void decodeTrailing2() throws Exception {
-        assertIOException("truncated", "Zm9vYmFy12");
-    }
-
-    // If there are valid trailing Base64 chars, complain
-    @Test
-    public void decodeTrailing3() throws Exception {
-        assertIOException("truncated", "Zm9vYmFy123");
-    }
-
-    @Test
-    public void decodeTrailingJunk() throws Exception {
-        assertEncoded("foobar", "Zm9vYmFy!!!");
-    }
-
-    /**
-     * Test our decode with pad character in the middle.
-     * Continues provided that the padding is in the correct place,
-     * i.e. concatenated valid strings decode OK.
-     */
-    @Test
-    public void decodeWithInnerPad() throws Exception {
-        assertEncoded("Hello WorldHello World", "SGVsbG8gV29ybGQ=SGVsbG8gV29ybGQ=");
-    }
-
-    // These inputs cause java.lang.ArrayIndexOutOfBoundsException
-    // in the Java 6 method DatatypeConverter.parseBase64Binary(String)
-    // The non-ASCII characters should just be ignored
-    @Test
-    public void nonASCIIcharacter() throws Exception {
-        assertEncoded("f", "Zg=À="); // A-grave
-        assertEncoded("f", "Zg=\u0100=");
-    }
-
-    /**
-     * Ignores non-BASE64 bytes.
-     */
-    @Test
-    public void nonBase64Bytes() throws Exception {
-        assertEncoded("Hello World", "S?G!V%sbG 8g\rV\t\n29ybGQ*=");
-    }
-
-    /**
-     * Tests RFC 4648 section 10 test vectors.
-     * <ul>
-     * <li>BASE64("") = ""</li>
-     * <li>BASE64("f") = "Zg=="</li>
-     * <li>BASE64("fo") = "Zm8="</li>
-     * <li>BASE64("foo") = "Zm9v"</li>
-     * <li>BASE64("foob") = "Zm9vYg=="</li>
-     * <li>BASE64("fooba") = "Zm9vYmE="</li>
-     * <li>BASE64("foobar") = "Zm9vYmFy"</li>
-     * </ul>
-     *
-     * @see <a href="http://tools.ietf.org/html/rfc4648">http://tools.ietf.org/html/rfc4648</a>
-     */
-    @Test
-    public void rfc4648Section10Decode() throws Exception {
-        assertEncoded("", "");
-        assertEncoded("f", "Zg==");
-        assertEncoded("fo", "Zm8=");
-        assertEncoded("foo", "Zm9v");
-        assertEncoded("foob", "Zm9vYg==");
-        assertEncoded("fooba", "Zm9vYmE=");
-        assertEncoded("foobar", "Zm9vYmFy");
-    }
-
-    @Test
-    public void truncatedString() {
-        final byte[] x = {'n'};
-        assertThrows(IOException.class, () -> Base64Decoder.decode(x, new ByteArrayOutputStream()));
-    }
-
-}