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 1b0d6f5bb3df6e5ceaaafa1374828fe4171016ce
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sun Jul 23 08:28:31 2023 -0400

    Use var
---
 .../fileupload2/core/AbstractFileUpload.java       | 62 ++++++++---------
 .../commons/fileupload2/core/DiskFileItem.java     | 30 ++++----
 .../fileupload2/core/FileItemHeadersImpl.java      |  4 +-
 .../fileupload2/core/FileItemInputImpl.java        |  5 +-
 .../core/FileItemInputIteratorImpl.java            | 23 +++----
 .../apache/commons/fileupload2/core/MimeUtils.java | 42 ++++++------
 .../commons/fileupload2/core/MultipartInput.java   | 36 +++++-----
 .../commons/fileupload2/core/ParameterParser.java  | 14 ++--
 .../fileupload2/core/QuotedPrintableDecoder.java   | 20 +++---
 .../commons/fileupload2/core/RFC2231Utils.java     | 24 +++----
 .../fileupload2/core/AbstractFileUploadTest.java   | 71 ++++++++++---------
 .../core/AbstractFileUploadWrapper.java            |  2 +-
 .../core/AbstractProgressListenerTest.java         | 37 +++++-----
 .../fileupload2/core/AbstractSizesTest.java        | 48 +++++++------
 .../fileupload2/core/AbstractStreamingTest.java    | 79 +++++++++++-----------
 .../fileupload2/core/DiskFileItemFactoryTest.java  |  9 ++-
 .../core/DiskFileItemSerializeTest.java            | 35 +++++-----
 .../commons/fileupload2/core/DiskFileItemTest.java |  7 +-
 .../fileupload2/core/FileItemHeadersTest.java      |  4 +-
 .../fileupload2/core/MultipartStreamTest.java      | 26 +++----
 .../fileupload2/core/ParameterParserTest.java      | 38 +++++------
 .../core/QuotedPrintableDecoderTestCase.java       | 14 ++--
 .../fileupload2/core/RFC2231UtilityTestCase.java   | 14 ++--
 .../jakarta/JakartaMockServletHttpRequest.java     |  2 +-
 .../jakarta/JakartaServletFileUploadDiskTest.java  | 21 +++---
 .../jakarta/JakartaServletFileUploadTest.java      | 21 +++---
 .../javax/JavaxHttpServletRequestFactory.java      |  8 +--
 .../javax/JavaxServletFileUploadDiskTest.java      | 46 ++++++-------
 .../javax/JavaxServletFileUploadTest.java          | 46 ++++++-------
 .../portlet/JavaxPortletFileUploadTest.java        |  7 +-
 30 files changed, 386 insertions(+), 409 deletions(-)

diff --git 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/AbstractFileUpload.java
 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/AbstractFileUpload.java
index a25506e9..76fd84ed 100644
--- 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/AbstractFileUpload.java
+++ 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/AbstractFileUpload.java
@@ -17,8 +17,6 @@
 package org.apache.commons.fileupload2.core;
 
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
@@ -114,7 +112,7 @@ public abstract class AbstractFileUpload<R, I extends 
FileItem<I>, F extends Fil
      * @return {@code true} if the request is multipart; {@code false} 
otherwise.
      */
     public static final boolean isMultipartContent(final RequestContext ctx) {
-        final String contentType = ctx.getContentType();
+        final var contentType = ctx.getContentType();
         if (contentType == null) {
             return false;
         }
@@ -158,11 +156,11 @@ public abstract class AbstractFileUpload<R, I extends 
FileItem<I>, F extends Fil
      * @return The boundary, as a byte array.
      */
     public byte[] getBoundary(final String contentType) {
-        final ParameterParser parser = new ParameterParser();
+        final var parser = new ParameterParser();
         parser.setLowerCaseNames(true);
         // Parameter parser can handle null input
-        final Map<String, String> params = parser.parse(contentType, new 
char[] { ';', ',' });
-        final String boundaryStr = params.get(BOUNDARY_KEY);
+        final var params = parser.parse(contentType, new char[] { ';', ',' });
+        final var boundaryStr = params.get(BOUNDARY_KEY);
         return boundaryStr != null ? 
boundaryStr.getBytes(StandardCharsets.ISO_8859_1) : null;
     }
 
@@ -185,10 +183,10 @@ public abstract class AbstractFileUpload<R, I extends 
FileItem<I>, F extends Fil
     private String getFieldName(final String contentDisposition) {
         String fieldName = null;
         if (contentDisposition != null && 
contentDisposition.toLowerCase(Locale.ENGLISH).startsWith(FORM_DATA)) {
-            final ParameterParser parser = new ParameterParser();
+            final var parser = new ParameterParser();
             parser.setLowerCaseNames(true);
             // Parameter parser can handle null input
-            final Map<String, String> params = 
parser.parse(contentDisposition, ';');
+            final var params = parser.parse(contentDisposition, ';');
             fieldName = params.get(NAME_KEY);
             if (fieldName != null) {
                 fieldName = fieldName.trim();
@@ -235,12 +233,12 @@ public abstract class AbstractFileUpload<R, I extends 
FileItem<I>, F extends Fil
     private String getFileName(final String contentDisposition) {
         String fileName = null;
         if (contentDisposition != null) {
-            final String cdl = contentDisposition.toLowerCase(Locale.ENGLISH);
+            final var cdl = contentDisposition.toLowerCase(Locale.ENGLISH);
             if (cdl.startsWith(FORM_DATA) || cdl.startsWith(ATTACHMENT)) {
-                final ParameterParser parser = new ParameterParser();
+                final var parser = new ParameterParser();
                 parser.setLowerCaseNames(true);
                 // Parameter parser can handle null input
-                final Map<String, String> params = 
parser.parse(contentDisposition, ';');
+                final var params = parser.parse(contentDisposition, ';');
                 if (params.containsKey(FILENAME_KEY)) {
                     fileName = params.get(FILENAME_KEY);
                     if (fileName != null) {
@@ -311,20 +309,20 @@ public abstract class AbstractFileUpload<R, I extends 
FileItem<I>, F extends Fil
      * @return A {@code Map} containing the parsed HTTP request headers.
      */
     public FileItemHeaders getParsedHeaders(final String headerPart) {
-        final int len = headerPart.length();
-        final FileItemHeaders headers = newFileItemHeaders();
-        int start = 0;
+        final var len = headerPart.length();
+        final var headers = newFileItemHeaders();
+        var start = 0;
         for (;;) {
-            int end = parseEndOfLine(headerPart, start);
+            var end = parseEndOfLine(headerPart, start);
             if (start == end) {
                 break;
             }
-            final StringBuilder header = new 
StringBuilder(headerPart.substring(start, end));
+            final var header = new StringBuilder(headerPart.substring(start, 
end));
             start = end + 2;
             while (start < len) {
-                int nonWs = start;
+                var nonWs = start;
                 while (nonWs < len) {
-                    final char c = headerPart.charAt(nonWs);
+                    final var c = headerPart.charAt(nonWs);
                     if (c != ' ' && c != '\t') {
                         break;
                     }
@@ -380,9 +378,9 @@ public abstract class AbstractFileUpload<R, I extends 
FileItem<I>, F extends Fil
      * @return Index of the \r\n sequence, which indicates end of line.
      */
     private int parseEndOfLine(final String headerPart, final int end) {
-        int index = end;
+        var index = end;
         for (;;) {
-            final int offset = headerPart.indexOf('\r', index);
+            final var offset = headerPart.indexOf('\r', index);
             if (offset == -1 || offset + 1 >= headerPart.length()) {
                 throw new IllegalStateException("Expected headers to be 
terminated by an empty line.");
             }
@@ -400,13 +398,13 @@ public abstract class AbstractFileUpload<R, I extends 
FileItem<I>, F extends Fil
      * @param header  Map where to store the current header.
      */
     private void parseHeaderLine(final FileItemHeaders headers, final String 
header) {
-        final int colonOffset = header.indexOf(':');
+        final var colonOffset = header.indexOf(':');
         if (colonOffset == -1) {
             // This header line is malformed, skip it.
             return;
         }
-        final String headerName = header.substring(0, colonOffset).trim();
-        final String headerValue = header.substring(colonOffset + 1).trim();
+        final var headerName = header.substring(0, colonOffset).trim();
+        final var headerValue = header.substring(colonOffset + 1).trim();
         headers.addHeader(headerName, headerValue);
     }
 
@@ -427,12 +425,12 @@ public abstract class AbstractFileUpload<R, I extends 
FileItem<I>, F extends Fil
      * @throws FileUploadException if there are problems reading/parsing the 
request or storing files.
      */
     public Map<String, List<I>> parseParameterMap(final RequestContext ctx) 
throws FileUploadException {
-        final List<I> items = parseRequest(ctx);
+        final var items = parseRequest(ctx);
         final Map<String, List<I>> itemsMap = new HashMap<>(items.size());
 
         for (final I fileItem : items) {
-            final String fieldName = fileItem.getFieldName();
-            final List<I> mappedItems = itemsMap.computeIfAbsent(fieldName, k 
-> new ArrayList<>());
+            final var fieldName = fileItem.getFieldName();
+            final var mappedItems = itemsMap.computeIfAbsent(fieldName, k -> 
new ArrayList<>());
             mappedItems.add(fileItem);
         }
 
@@ -457,10 +455,10 @@ public abstract class AbstractFileUpload<R, I extends 
FileItem<I>, F extends Fil
      */
     public List<I> parseRequest(final RequestContext requestContext) throws 
FileUploadException {
         final List<I> itemList = new ArrayList<>();
-        boolean successful = false;
+        var successful = false;
         try {
-            final F fileItemFactory = 
Objects.requireNonNull(getFileItemFactory(), "No FileItemFactory has been 
set.");
-            final byte[] buffer = new byte[IOUtils.DEFAULT_BUFFER_SIZE];
+            final var fileItemFactory = 
Objects.requireNonNull(getFileItemFactory(), "No FileItemFactory has been 
set.");
+            final var buffer = new byte[IOUtils.DEFAULT_BUFFER_SIZE];
             getItemIterator(requestContext).forEachRemaining(fileItemInput -> {
                 if (itemList.size() == fileCountMax) {
                     // The next item will exceed the limit.
@@ -468,7 +466,7 @@ public abstract class AbstractFileUpload<R, I extends 
FileItem<I>, F extends Fil
                 }
                 // Don't use getName() here to prevent an 
InvalidFileNameException.
                 // @formatter:off
-                final I fileItem = fileItemFactory.fileItemBuilder()
+                final var fileItem = fileItemFactory.fileItemBuilder()
                     .setFieldName(fileItemInput.getFieldName())
                     .setContentType(fileItemInput.getContentType())
                     .setFormField(fileItemInput.isFormField())
@@ -477,8 +475,8 @@ public abstract class AbstractFileUpload<R, I extends 
FileItem<I>, F extends Fil
                     .get();
                 // @formatter:on
                 itemList.add(fileItem);
-                try (InputStream inputStream = fileItemInput.getInputStream();
-                        OutputStream outputStream = 
fileItem.getOutputStream()) {
+                try (var inputStream = fileItemInput.getInputStream();
+                        var outputStream = fileItem.getOutputStream()) {
                     IOUtils.copyLarge(inputStream, outputStream, buffer);
                 } catch (final FileUploadException e) {
                     throw e;
diff --git 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/DiskFileItem.java
 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/DiskFileItem.java
index 0d3dc802..c21a7480 100644
--- 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/DiskFileItem.java
+++ 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/DiskFileItem.java
@@ -29,13 +29,11 @@ import java.nio.file.InvalidPathException;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.StandardCopyOption;
-import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import 
org.apache.commons.fileupload2.core.FileItemFactory.AbstractFileItemBuilder;
 import org.apache.commons.io.Charsets;
-import org.apache.commons.io.FileCleaningTracker;
 import org.apache.commons.io.build.AbstractOrigin;
 import org.apache.commons.io.file.PathUtils;
 import org.apache.commons.io.function.Uncheck;
@@ -100,9 +98,9 @@ public final class DiskFileItem implements 
FileItem<DiskFileItem> {
          */
         @Override
         public DiskFileItem get() {
-            final DiskFileItem diskFileItem = new DiskFileItem(getFieldName(), 
getContentType(), isFormField(), getFileName(), getBufferSize(), getPath(),
+            final var diskFileItem = new DiskFileItem(getFieldName(), 
getContentType(), isFormField(), getFileName(), getBufferSize(), getPath(),
                     getFileItemHeaders(), getCharset());
-            final FileCleaningTracker tracker = getFileCleaningTracker();
+            final var tracker = getFileCleaningTracker();
             if (tracker != null) {
                 tracker.track(diskFileItem.getTempFile().toFile(), 
diskFileItem);
             }
@@ -147,11 +145,11 @@ public final class DiskFileItem implements 
FileItem<DiskFileItem> {
     public static String checkFileName(final String fileName) {
         if (fileName != null) {
             // Specific NUL check to build a better exception message.
-            final int indexOf0 = fileName.indexOf(0);
+            final var indexOf0 = fileName.indexOf(0);
             if (indexOf0 != -1) {
-                final StringBuilder sb = new StringBuilder();
-                for (int i = 0; i < fileName.length(); i++) {
-                    final char c = fileName.charAt(i);
+                final var sb = new StringBuilder();
+                for (var i = 0; i < fileName.length(); i++) {
+                    final var c = fileName.charAt(i);
                     switch (c) {
                     case 0:
                         sb.append("\\0");
@@ -175,9 +173,9 @@ public final class DiskFileItem implements 
FileItem<DiskFileItem> {
      * @return A String with the non-random looking instance identifier.
      */
     private static String getUniqueId() {
-        final int limit = 100_000_000;
-        final int current = COUNTER.getAndIncrement();
-        String id = Integer.toString(current);
+        final var limit = 100_000_000;
+        final var current = COUNTER.getAndIncrement();
+        var id = Integer.toString(current);
 
         // If you manage to get more than 100 million of ids, you'll
         // start getting ids longer than 8 characters.
@@ -281,7 +279,7 @@ public final class DiskFileItem implements 
FileItem<DiskFileItem> {
     @Override
     public DiskFileItem delete() throws IOException {
         cachedContent = null;
-        final Path outputFile = getPath();
+        final var outputFile = getPath();
         if (outputFile != null && !isInMemory() && Files.exists(outputFile)) {
             Files.delete(outputFile);
         }
@@ -314,10 +312,10 @@ public final class DiskFileItem implements 
FileItem<DiskFileItem> {
      * @return The content charset passed by the agent or {@code null} if not 
defined.
      */
     public Charset getCharset() {
-        final ParameterParser parser = new ParameterParser();
+        final var parser = new ParameterParser();
         parser.setLowerCaseNames(true);
         // Parameter parser can handle null input
-        final Map<String, String> params = parser.parse(getContentType(), ';');
+        final var params = parser.parse(getContentType(), ';');
         return Charsets.toCharset(params.get("charset"), charsetDefault);
     }
 
@@ -576,13 +574,13 @@ public final class DiskFileItem implements 
FileItem<DiskFileItem> {
     @Override
     public DiskFileItem write(final Path file) throws IOException {
         if (isInMemory()) {
-            try (OutputStream fout = Files.newOutputStream(file)) {
+            try (var fout = Files.newOutputStream(file)) {
                 fout.write(get());
             } catch (final IOException e) {
                 throw new IOException("Unexpected output data", e);
             }
         } else {
-            final Path outputFile = getPath();
+            final var outputFile = getPath();
             if (outputFile == null) {
                 /*
                  * For whatever reason we cannot write the file to disk.
diff --git 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/FileItemHeadersImpl.java
 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/FileItemHeadersImpl.java
index a20264ec..1f5f46c2 100644
--- 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/FileItemHeadersImpl.java
+++ 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/FileItemHeadersImpl.java
@@ -50,7 +50,7 @@ class FileItemHeadersImpl implements FileItemHeaders {
      */
     @Override
     public String getHeader(final String name) {
-        final List<String> headerValueList = getList(name);
+        final var headerValueList = getList(name);
         if (null == headerValueList) {
             return null;
         }
@@ -70,7 +70,7 @@ class FileItemHeadersImpl implements FileItemHeaders {
      */
     @Override
     public Iterator<String> getHeaders(final String name) {
-        List<String> headerValueList = getList(name);
+        var headerValueList = getList(name);
         if (null == headerValueList) {
             headerValueList = Collections.emptyList();
         }
diff --git 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/FileItemInputImpl.java
 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/FileItemInputImpl.java
index b3c7f715..f39b9066 100644
--- 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/FileItemInputImpl.java
+++ 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/FileItemInputImpl.java
@@ -20,7 +20,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.nio.file.InvalidPathException;
 
-import org.apache.commons.fileupload2.core.MultipartInput.ItemInputStream;
 import org.apache.commons.io.input.BoundedInputStream;
 
 /**
@@ -89,13 +88,13 @@ class FileItemInputImpl implements FileItemInput {
         this.fieldName = fieldName;
         this.contentType = contentType;
         this.formField = formField;
-        final long fileSizeMax = fileItemInputIteratorImpl.getFileSizeMax();
+        final var fileSizeMax = fileItemInputIteratorImpl.getFileSizeMax();
         if (fileSizeMax != -1 && contentLength != -1 && contentLength > 
fileSizeMax) {
             throw new FileUploadByteCountLimitException(String.format("The 
field %s exceeds its maximum permitted size of %s bytes.", fieldName, 
fileSizeMax),
                     contentLength, fileSizeMax, fileName, fieldName);
         }
         // OK to construct stream now
-        final ItemInputStream itemInputStream = 
fileItemInputIteratorImpl.getMultiPartInput().newInputStream();
+        final var itemInputStream = 
fileItemInputIteratorImpl.getMultiPartInput().newInputStream();
         InputStream istream = itemInputStream;
         if (fileSizeMax != -1) {
             istream = new BoundedInputStream(istream, fileSizeMax) {
diff --git 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/FileItemInputIteratorImpl.java
 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/FileItemInputIteratorImpl.java
index 09a8db3e..c01f2ae3 100644
--- 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/FileItemInputIteratorImpl.java
+++ 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/FileItemInputIteratorImpl.java
@@ -18,7 +18,6 @@ package org.apache.commons.fileupload2.core;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.nio.charset.Charset;
 import java.util.Iterator;
 import java.util.Locale;
 import java.util.NoSuchElementException;
@@ -128,7 +127,7 @@ class FileItemInputIteratorImpl implements 
FileItemInputIterator {
             currentItem.close();
             currentItem = null;
         }
-        final MultipartInput multi = getMultiPartInput();
+        final var multi = getMultiPartInput();
         for (;;) {
             final boolean nextPart;
             if (skipPreamble) {
@@ -147,21 +146,21 @@ class FileItemInputIteratorImpl implements 
FileItemInputIterator {
                 currentFieldName = null;
                 continue;
             }
-            final FileItemHeaders headers = 
fileUpload.getParsedHeaders(multi.readHeaders());
+            final var headers = 
fileUpload.getParsedHeaders(multi.readHeaders());
             if (currentFieldName == null) {
                 // We're parsing the outer multipart
-                final String fieldName = fileUpload.getFieldName(headers);
+                final var fieldName = fileUpload.getFieldName(headers);
                 if (fieldName != null) {
-                    final String subContentType = 
headers.getHeader(AbstractFileUpload.CONTENT_TYPE);
+                    final var subContentType = 
headers.getHeader(AbstractFileUpload.CONTENT_TYPE);
                     if (subContentType != null && 
subContentType.toLowerCase(Locale.ENGLISH).startsWith(AbstractFileUpload.MULTIPART_MIXED))
 {
                         currentFieldName = fieldName;
                         // Multiple files associated with this field name
-                        final byte[] subBoundary = 
fileUpload.getBoundary(subContentType);
+                        final var subBoundary = 
fileUpload.getBoundary(subContentType);
                         multi.setBoundary(subBoundary);
                         skipPreamble = true;
                         continue;
                     }
-                    final String fileName = fileUpload.getFileName(headers);
+                    final var fileName = fileUpload.getFileName(headers);
                     currentItem = new FileItemInputImpl(this, fileName, 
fieldName, headers.getHeader(AbstractFileUpload.CONTENT_TYPE), fileName == null,
                             getContentLength(headers));
                     currentItem.setHeaders(headers);
@@ -170,7 +169,7 @@ class FileItemInputIteratorImpl implements 
FileItemInputIterator {
                     return true;
                 }
             } else {
-                final String fileName = fileUpload.getFileName(headers);
+                final var fileName = fileUpload.getFileName(headers);
                 if (fileName != null) {
                     currentItem = new FileItemInputImpl(this, fileName, 
currentFieldName, headers.getHeader(AbstractFileUpload.CONTENT_TYPE), false,
                             getContentLength(headers));
@@ -228,14 +227,14 @@ class FileItemInputIteratorImpl implements 
FileItemInputIterator {
     }
 
     protected void init(final AbstractFileUpload<?, ?, ?> fileUploadBase, 
final RequestContext initContext) throws FileUploadException, IOException {
-        final String contentType = requestContext.getContentType();
+        final var contentType = requestContext.getContentType();
         if (null == contentType || 
!contentType.toLowerCase(Locale.ENGLISH).startsWith(AbstractFileUpload.MULTIPART))
 {
             throw new FileUploadContentTypeException(String.format("the 
request doesn't contain a %s or %s stream, content type header is %s",
                     AbstractFileUpload.MULTIPART_FORM_DATA, 
AbstractFileUpload.MULTIPART_MIXED, contentType), contentType);
         }
-        final long contentLengthInt = requestContext.getContentLength();
+        final var contentLengthInt = requestContext.getContentLength();
         // @formatter:off
-        final long requestSize = 
RequestContext.class.isAssignableFrom(requestContext.getClass())
+        final var requestSize = 
RequestContext.class.isAssignableFrom(requestContext.getClass())
                                  // Inline conditional is OK here 
CHECKSTYLE:OFF
                                  ? requestContext.getContentLength()
                                  : contentLengthInt;
@@ -260,7 +259,7 @@ class FileItemInputIteratorImpl implements 
FileItemInputIterator {
             inputStream = requestContext.getInputStream();
         }
 
-        final Charset charset = 
Charsets.toCharset(fileUploadBase.getHeaderCharset(), 
requestContext.getCharset());
+        final var charset = 
Charsets.toCharset(fileUploadBase.getHeaderCharset(), 
requestContext.getCharset());
         multiPartBoundary = fileUploadBase.getBoundary(contentType);
         if (multiPartBoundary == null) {
             IOUtils.closeQuietly(inputStream); // avoid possible resource leak
diff --git 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/MimeUtils.java
 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/MimeUtils.java
index d992b73f..667386b3 100644
--- 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/MimeUtils.java
+++ 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/MimeUtils.java
@@ -90,18 +90,18 @@ final class MimeUtils {
             return text;
         }
 
-        int offset = 0;
-        final int endOffset = text.length();
+        var offset = 0;
+        final var endOffset = text.length();
 
-        int startWhiteSpace = -1;
-        int endWhiteSpace = -1;
+        var startWhiteSpace = -1;
+        var endWhiteSpace = -1;
 
-        final StringBuilder decodedText = new StringBuilder(text.length());
+        final var decodedText = new StringBuilder(text.length());
 
-        boolean previousTokenEncoded = false;
+        var previousTokenEncoded = false;
 
         while (offset < endOffset) {
-            char ch = text.charAt(offset);
+            var ch = text.charAt(offset);
 
             // is this a whitespace character?
             if (LINEAR_WHITESPACE.indexOf(ch) != -1) { // whitespace found
@@ -119,7 +119,7 @@ final class MimeUtils {
                 }
             } else {
                 // we have a word token. We need to scan over the word and 
then try to parse it.
-                final int wordStart = offset;
+                final var wordStart = offset;
 
                 while (offset < endOffset) {
                     // step over the non white space characters.
@@ -132,12 +132,12 @@ final class MimeUtils {
                     // NB: Trailing whitespace on these header strings will 
just be discarded.
                 }
                 // pull out the word token.
-                final String word = text.substring(wordStart, offset);
+                final var word = text.substring(wordStart, offset);
                 // is the token encoded? decode the word
                 if (word.startsWith(ENCODED_TOKEN_MARKER)) {
                     try {
                         // if this gives a parsing failure, treat it like a 
non-encoded word.
-                        final String decodedWord = decodeWord(word);
+                        final var decodedWord = decodeWord(word);
 
                         // are any whitespace characters significant? Append 
'em if we've got 'em.
                         if (!previousTokenEncoded && startWhiteSpace != -1) {
@@ -186,34 +186,34 @@ final class MimeUtils {
         // encoded words start with the characters "=?". If this not an 
encoded word, we throw a
         // ParseException for the caller.
 
-        final int etmPos = word.indexOf(ENCODED_TOKEN_MARKER);
+        final var etmPos = word.indexOf(ENCODED_TOKEN_MARKER);
         if (etmPos != 0) {
             throw new ParseException("Invalid RFC 2047 encoded-word: " + word, 
etmPos);
         }
 
-        final int charsetPos = word.indexOf('?', 2);
+        final var charsetPos = word.indexOf('?', 2);
         if (charsetPos == -1) {
             throw new ParseException("Missing charset in RFC 2047 
encoded-word: " + word, charsetPos);
         }
 
         // pull out the character set information (this is the MIME name at 
this point).
-        final String charset = word.substring(2, 
charsetPos).toLowerCase(Locale.ENGLISH);
+        final var charset = word.substring(2, 
charsetPos).toLowerCase(Locale.ENGLISH);
 
         // now pull out the encoding token the same way.
-        final int encodingPos = word.indexOf('?', charsetPos + 1);
+        final var encodingPos = word.indexOf('?', charsetPos + 1);
         if (encodingPos == -1) {
             throw new ParseException("Missing encoding in RFC 2047 
encoded-word: " + word, encodingPos);
         }
 
-        final String encoding = word.substring(charsetPos + 1, encodingPos);
+        final var encoding = word.substring(charsetPos + 1, encodingPos);
 
         // and finally the encoded text.
-        final int encodedTextPos = word.indexOf(ENCODED_TOKEN_FINISHER, 
encodingPos + 1);
+        final var encodedTextPos = word.indexOf(ENCODED_TOKEN_FINISHER, 
encodingPos + 1);
         if (encodedTextPos == -1) {
             throw new ParseException("Missing encoded text in RFC 2047 
encoded-word: " + word, encodedTextPos);
         }
 
-        final String encodedText = word.substring(encodingPos + 1, 
encodedTextPos);
+        final var encodedText = word.substring(encodingPos + 1, 
encodedTextPos);
 
         // seems a bit silly to encode a null string, but easy to deal with.
         if (encodedText.isEmpty()) {
@@ -222,9 +222,9 @@ final class MimeUtils {
 
         try {
             // the decoder writes directly to an output stream.
-            final ByteArrayOutputStream out = new 
ByteArrayOutputStream(encodedText.length());
+            final var out = new ByteArrayOutputStream(encodedText.length());
 
-            final byte[] encodedData = 
encodedText.getBytes(StandardCharsets.US_ASCII);
+            final var encodedData = 
encodedText.getBytes(StandardCharsets.US_ASCII);
 
             // Base64 encoded?
             if (encoding.equals(BASE64_ENCODING_MARKER)) {
@@ -235,7 +235,7 @@ final class MimeUtils {
                 throw new UnsupportedEncodingException("Unknown RFC 2047 
encoding: " + encoding);
             }
             // get the decoded byte data and convert into a string.
-            final byte[] decodedData = out.toByteArray();
+            final var decodedData = out.toByteArray();
             return new String(decodedData, javaCharset(charset));
         } catch (final IOException e) {
             throw new UnsupportedEncodingException("Invalid RFC 2047 
encoding");
@@ -254,7 +254,7 @@ final class MimeUtils {
         if (charset == null) {
             return null;
         }
-        final String mappedCharset = 
MIME2JAVA.get(charset.toLowerCase(Locale.ENGLISH));
+        final var mappedCharset = 
MIME2JAVA.get(charset.toLowerCase(Locale.ENGLISH));
         // if there is no mapping, then the original name is used. Many of the 
MIME character set
         // names map directly back into Java. The reverse isn't necessarily 
true.
         return mappedCharset == null ? charset : mappedCharset;
diff --git 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/MultipartInput.java
 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/MultipartInput.java
index e004c864..0f1e7571 100644
--- 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/MultipartInput.java
+++ 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/MultipartInput.java
@@ -258,7 +258,7 @@ public final class MultipartInput {
                 input.close();
             } else {
                 for (;;) {
-                    int av = available();
+                    var av = available();
                     if (av == 0) {
                         av = makeAvailable();
                         if (av == 0) {
@@ -318,12 +318,12 @@ public final class MultipartInput {
             tail = pad;
 
             for (;;) {
-                final int bytesRead = input.read(buffer, tail, bufSize - tail);
+                final var bytesRead = input.read(buffer, tail, bufSize - tail);
                 if (bytesRead == -1) {
                     // The last pad amount is left in the buffer.
                     // Boundary can't be in there so signal an error
                     // condition.
-                    final String msg = "Stream ended unexpectedly";
+                    final var msg = "Stream ended unexpectedly";
                     throw new MalformedStreamException(msg);
                 }
                 if (notifier != null) {
@@ -332,7 +332,7 @@ public final class MultipartInput {
                 tail += bytesRead;
 
                 findSeparator();
-                final int av = available();
+                final var av = available();
 
                 if (av > 0 || pos != -1) {
                     return av;
@@ -375,7 +375,7 @@ public final class MultipartInput {
             if (len == 0) {
                 return 0;
             }
-            int res = available();
+            var res = available();
             if (res == 0) {
                 res = makeAvailable();
                 if (res == 0) {
@@ -399,14 +399,14 @@ public final class MultipartInput {
         @Override
         public long skip(final long bytes) throws IOException {
             checkOpen();
-            int av = available();
+            var av = available();
             if (av == 0) {
                 av = makeAvailable();
                 if (av == 0) {
                     return 0;
                 }
             }
-            final long res = Math.min(av, bytes);
+            final var res = Math.min(av, bytes);
             head += res;
             return res;
         }
@@ -565,7 +565,7 @@ public final class MultipartInput {
      * @return {@code true} if {@code count} first bytes in arrays {@code a} 
and {@code b} are equal.
      */
     static boolean arrayEquals(final byte[] a, final byte[] b, final int 
count) {
-        for (int i = 0; i < count; i++) {
+        for (var i = 0; i < count; i++) {
             if (a[i] != b[i]) {
                 return false;
             }
@@ -684,8 +684,8 @@ public final class MultipartInput {
      * Computes the table used for Knuth-Morris-Pratt search algorithm.
      */
     private void computeBoundaryTable() {
-        int position = 2;
-        int candidate = 0;
+        var position = 2;
+        var candidate = 0;
 
         boundaryTable[0] = -1;
         boundaryTable[1] = 0;
@@ -727,7 +727,7 @@ public final class MultipartInput {
      * @return The position of byte found, counting from beginning of the 
{@code buffer}, or {@code -1} if not found.
      */
     protected int findByte(final byte value, final int pos) {
-        for (int i = pos; i < tail; i++) {
+        for (var i = pos; i < tail; i++) {
             if (buffer[i] == value) {
                 return i;
             }
@@ -742,8 +742,8 @@ public final class MultipartInput {
      * @return The position of the boundary found, counting from the beginning 
of the {@code buffer}, or {@code -1} if not found.
      */
     protected int findSeparator() {
-        int bufferPos = this.head;
-        int tablePos = 0;
+        var bufferPos = this.head;
+        var tablePos = 0;
         while (bufferPos < this.tail) {
             while (tablePos >= 0 && buffer[bufferPos] != boundary[tablePos]) {
                 tablePos = boundaryTable[tablePos];
@@ -788,7 +788,7 @@ public final class MultipartInput {
      * @throws IOException              if an i/o error occurs.
      */
     public long readBodyData(final OutputStream output) throws 
MalformedStreamException, IOException {
-        try (ItemInputStream inputStream = newInputStream()) {
+        try (var inputStream = newInputStream()) {
             return IOUtils.copyLarge(inputStream, output);
         }
     }
@@ -801,7 +801,7 @@ public final class MultipartInput {
      * @throws MalformedStreamException if the stream ends unexpectedly or 
fails to follow required syntax.
      */
     public boolean readBoundary() throws FileUploadSizeException, 
MalformedStreamException {
-        final byte[] marker = new byte[2];
+        final var marker = new byte[2];
         final boolean nextChunk;
         head += boundaryLength;
         try {
@@ -866,11 +866,11 @@ public final class MultipartInput {
      * @throws MalformedStreamException if the stream ends unexpectedly.
      */
     public String readHeaders() throws FileUploadSizeException, 
MalformedStreamException {
-        int i = 0;
+        var i = 0;
         byte b;
         // to support multi-byte characters
-        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        int size = 0;
+        final var baos = new ByteArrayOutputStream();
+        var size = 0;
         while (i < HEADER_SEPARATOR.length) {
             try {
                 b = readByte();
diff --git 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/ParameterParser.java
 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/ParameterParser.java
index 99af615f..976c7124 100644
--- 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/ParameterParser.java
+++ 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/ParameterParser.java
@@ -122,7 +122,7 @@ public class ParameterParser {
      * @return {@code true} if the character is present in the array of 
characters, {@code false} otherwise.
      */
     private boolean isOneOf(final char ch, final char[] charray) {
-        boolean result = false;
+        var result = false;
         for (final char element : charray) {
             if (ch == element) {
                 result = true;
@@ -160,7 +160,7 @@ public class ParameterParser {
         if (charArray == null) {
             return new HashMap<>();
         }
-        final HashMap<String, String> params = new HashMap<>();
+        final var params = new HashMap<String, String>();
         this.chars = charArray.clone();
         this.pos = offset;
         this.len = length;
@@ -222,11 +222,11 @@ public class ParameterParser {
         if (separators == null || separators.length == 0) {
             return new HashMap<>();
         }
-        char separator = separators[0];
+        var separator = separators[0];
         if (str != null) {
-            int idx = str.length();
+            var idx = str.length();
             for (final char separator2 : separators) {
-                final int tmp = str.indexOf(separator2);
+                final var tmp = str.indexOf(separator2);
                 if (tmp != -1 && tmp < idx) {
                     idx = tmp;
                     separator = separator2;
@@ -246,8 +246,8 @@ public class ParameterParser {
         char ch;
         i1 = pos;
         i2 = pos;
-        boolean quoted = false;
-        boolean charEscaped = false;
+        var quoted = false;
+        var charEscaped = false;
         while (hasChar()) {
             ch = chars[pos];
             if (!quoted && isOneOf(ch, terminators)) {
diff --git 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/QuotedPrintableDecoder.java
 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/QuotedPrintableDecoder.java
index 6085d750..263238be 100644
--- 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/QuotedPrintableDecoder.java
+++ 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/QuotedPrintableDecoder.java
@@ -38,13 +38,13 @@ final class QuotedPrintableDecoder {
      * @throws IOException if an IO error occurs
      */
     public static int decode(final byte[] data, final OutputStream out) throws 
IOException {
-        int off = 0;
-        final int length = data.length;
-        final int endOffset = off + length;
-        int bytesWritten = 0;
+        var off = 0;
+        final var length = data.length;
+        final var endOffset = off + length;
+        var bytesWritten = 0;
 
         while (off < endOffset) {
-            final byte ch = data[off++];
+            final var ch = data[off++];
 
             // space characters were translated to '_' on encode, so we need 
to translate them back.
             if (ch == '_') {
@@ -56,8 +56,8 @@ final class QuotedPrintableDecoder {
                     throw new IOException("Invalid quoted printable encoding; 
truncated escape sequence");
                 }
 
-                final byte b1 = data[off++];
-                final byte b2 = data[off++];
+                final var b1 = data[off++];
+                final var b2 = data[off++];
 
                 // we've found an encoded carriage return. The next char needs 
to be a newline
                 if (b1 == '\r') {
@@ -68,8 +68,8 @@ final class QuotedPrintableDecoder {
                     // on decode.
                 } else {
                     // this is a hex pair we need to convert back to a single 
byte.
-                    final int c1 = hexToBinary(b1);
-                    final int c2 = hexToBinary(b2);
+                    final var c1 = hexToBinary(b1);
+                    final var c2 = hexToBinary(b2);
                     out.write(c1 << UPPER_NIBBLE_SHIFT | c2);
                     // 3 bytes in, one byte out
                     bytesWritten++;
@@ -93,7 +93,7 @@ final class QuotedPrintableDecoder {
      */
     private static int hexToBinary(final byte b) throws IOException {
         // CHECKSTYLE IGNORE MagicNumber FOR NEXT 1 LINE
-        final int i = Character.digit((char) b, 16);
+        final var i = Character.digit((char) b, 16);
         if (i == -1) {
             throw new IOException("Invalid quoted printable encoding: not a 
valid hex digit: " + b);
         }
diff --git 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/RFC2231Utils.java
 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/RFC2231Utils.java
index c95d29d3..c45d414e 100644
--- 
a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/RFC2231Utils.java
+++ 
b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/RFC2231Utils.java
@@ -51,7 +51,7 @@ final class RFC2231Utils {
 
     // create a ASCII decoded array of Hexadecimal values
     static {
-        for (int i = 0; i < HEX_DIGITS.length; i++) {
+        for (var i = 0; i < HEX_DIGITS.length; i++) {
             HEX_DECODE[HEX_DIGITS[i]] = (byte) i;
             HEX_DECODE[Character.toLowerCase(HEX_DIGITS[i])] = (byte) i;
         }
@@ -71,18 +71,18 @@ final class RFC2231Utils {
      * @throws UnsupportedEncodingException The requested character set wasn't 
found.
      */
     static String decodeText(final String encodedText) throws 
UnsupportedEncodingException {
-        final int langDelimitStart = encodedText.indexOf('\'');
+        final var langDelimitStart = encodedText.indexOf('\'');
         if (langDelimitStart == -1) {
             // missing charset
             return encodedText;
         }
-        final String mimeCharset = encodedText.substring(0, langDelimitStart);
-        final int langDelimitEnd = encodedText.indexOf('\'', langDelimitStart 
+ 1);
+        final var mimeCharset = encodedText.substring(0, langDelimitStart);
+        final var langDelimitEnd = encodedText.indexOf('\'', langDelimitStart 
+ 1);
         if (langDelimitEnd == -1) {
             // missing language
             return encodedText;
         }
-        final byte[] bytes = fromHex(encodedText.substring(langDelimitEnd + 
1));
+        final var bytes = fromHex(encodedText.substring(langDelimitEnd + 1));
         return new String(bytes, getJavaCharset(mimeCharset));
     }
 
@@ -93,16 +93,16 @@ final class RFC2231Utils {
      * @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++);
+        final var shift = 4;
+        final var out = new ByteArrayOutputStream(text.length());
+        for (var i = 0; i < text.length();) {
+            final var c = text.charAt(i++);
             if (c == '%') {
                 if (i > text.length() - 2) {
                     break; // unterminated sequence
                 }
-                final byte b1 = HEX_DECODE[text.charAt(i++) & MASK];
-                final byte b2 = HEX_DECODE[text.charAt(i++) & MASK];
+                final var b1 = HEX_DECODE[text.charAt(i++) & MASK];
+                final var b2 = HEX_DECODE[text.charAt(i++) & MASK];
                 out.write(b1 << shift | b2);
             } else {
                 out.write((byte) c);
@@ -137,7 +137,7 @@ final class RFC2231Utils {
      */
     static String stripDelimiter(final String paramName) {
         if (hasEncodedValue(paramName)) {
-            final StringBuilder paramBuilder = new StringBuilder(paramName);
+            final var paramBuilder = new StringBuilder(paramName);
             paramBuilder.deleteCharAt(paramName.lastIndexOf('*'));
             return paramBuilder.toString();
         }
diff --git 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractFileUploadTest.java
 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractFileUploadTest.java
index 35112c2d..78979191 100644
--- 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractFileUploadTest.java
+++ 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractFileUploadTest.java
@@ -23,7 +23,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
-import java.util.List;
 
 import org.junit.jupiter.api.Test;
 
@@ -44,8 +43,8 @@ public abstract class AbstractFileUploadTest<AFU extends 
AbstractFileUpload<R, I
     }
 
     private void assertHeaders(final String[] headerNames, final String[] 
headerValues, final I fileItems, final int index) {
-        for (int i = 0; i < headerNames.length; i++) {
-            final String value = 
fileItems.getHeaders().getHeader(headerNames[i]);
+        for (var i = 0; i < headerNames.length; i++) {
+            final var value = fileItems.getHeaders().getHeader(headerNames[i]);
             if (i == index) {
                 assertEquals(headerValues[i], value);
             } else {
@@ -62,7 +61,7 @@ public abstract class AbstractFileUploadTest<AFU extends 
AbstractFileUpload<R, I
     @Test
     public void testContentTypeAttachment() throws IOException {
         // @formatter:off
-        final List<I> fileItems = parseUpload(upload,
+        final var fileItems = parseUpload(upload,
                 "-----1234\r\n" +
                 "content-disposition: form-data; name=\"field1\"\r\n" +
                 "\r\n" +
@@ -81,12 +80,12 @@ public abstract class AbstractFileUploadTest<AFU extends 
AbstractFileUpload<R, I
         // @formatter:on
         assertEquals(2, fileItems.size());
 
-        final I field = fileItems.get(0);
+        final var field = fileItems.get(0);
         assertEquals("field1", field.getFieldName());
         assertTrue(field.isFormField());
         assertEquals("Joe Blow", field.getString());
 
-        final I fileItem = fileItems.get(1);
+        final var fileItem = fileItems.get(1);
         assertEquals("pics", fileItem.getFieldName());
         assertFalse(fileItem.isFormField());
         assertEquals("... contents of file1.txt ...", fileItem.getString());
@@ -102,7 +101,7 @@ public abstract class AbstractFileUploadTest<AFU extends 
AbstractFileUpload<R, I
     @Test
     public void testEmptyFile() throws FileUploadException {
         // @formatter:off
-        final List<I> fileItems = parseUpload (upload,
+        final var fileItems = parseUpload (upload,
                                                 "-----1234\r\n" +
                                                 "Content-Disposition: 
form-data; name=\"file\"; filename=\"\"\r\n" +
                                                 "\r\n" +
@@ -111,7 +110,7 @@ public abstract class AbstractFileUploadTest<AFU extends 
AbstractFileUpload<R, I
         // @formatter:on
         assertEquals(1, fileItems.size());
 
-        final I file = fileItems.get(0);
+        final var file = fileItems.get(0);
         assertFalse(file.isFormField());
         assertEquals("", file.getString());
         assertEquals("", file.getName());
@@ -120,7 +119,7 @@ public abstract class AbstractFileUploadTest<AFU extends 
AbstractFileUpload<R, I
     @Test
     public void testFilenameCaseSensitivity() throws IOException {
         // @formatter:off
-        final List<I> fileItems = parseUpload(upload,
+        final var fileItems = parseUpload(upload,
                                                "-----1234\r\n" +
                                                "Content-Disposition: 
form-data; "
                                              + "name=\"FiLe\"; 
filename=\"FOO.tab\"\r\n" +
@@ -132,7 +131,7 @@ public abstract class AbstractFileUploadTest<AFU extends 
AbstractFileUpload<R, I
         // @formatter:on
         assertEquals(1, fileItems.size());
 
-        final I file = fileItems.get(0);
+        final var file = fileItems.get(0);
         assertEquals("FiLe", file.getFieldName());
         assertEquals("FOO.tab", file.getName());
     }
@@ -140,7 +139,7 @@ public abstract class AbstractFileUploadTest<AFU extends 
AbstractFileUpload<R, I
     @Test
     public void testFileUpload() throws IOException {
         // @formatter:off
-        final List<I> fileItems = parseUpload(upload,
+        final var fileItems = parseUpload(upload,
                                                "-----1234\r\n" +
                                                "Content-Disposition: "
                                                + "form-data; name=\"file\"; 
filename=\"foo.tab\"\r\n" +
@@ -164,24 +163,24 @@ public abstract class AbstractFileUploadTest<AFU extends 
AbstractFileUpload<R, I
         // @formatter:on
         assertEquals(4, fileItems.size());
 
-        final I file = fileItems.get(0);
+        final var file = fileItems.get(0);
         assertEquals("file", file.getFieldName());
         assertFalse(file.isFormField());
         assertEquals("This is the content of the file\n", file.getString());
         assertEquals("text/whatever", file.getContentType());
         assertEquals("foo.tab", file.getName());
 
-        final I field = fileItems.get(1);
+        final var field = fileItems.get(1);
         assertEquals("field", field.getFieldName());
         assertTrue(field.isFormField());
         assertEquals("fieldValue", field.getString());
 
-        final I multi0 = fileItems.get(2);
+        final var multi0 = fileItems.get(2);
         assertEquals("multi", multi0.getFieldName());
         assertTrue(multi0.isFormField());
         assertEquals("value1", multi0.getString());
 
-        final I multi1 = fileItems.get(3);
+        final var multi1 = fileItems.get(3);
         assertEquals("multi", multi1.getFieldName());
         assertTrue(multi1.isFormField());
         assertEquals("value2", multi1.getString());
@@ -197,7 +196,7 @@ public abstract class AbstractFileUploadTest<AFU extends 
AbstractFileUpload<R, I
         final String[] headerNames = { "SomeHeader", "OtherHeader", 
"YetAnotherHeader", "WhatAHeader" };
         final String[] headerValues = { "present", "Is there", "Here", "Is 
That" };
         // @formatter:off
-        final List<I> fileItems = parseUpload(upload,
+        final var fileItems = parseUpload(upload,
                                                "-----1234\r\n" +
                                                "Content-Disposition: 
form-data; name=\"file\"; "
                                              + "filename=\"foo.tab\"\r\n" +
@@ -227,16 +226,16 @@ public abstract class AbstractFileUploadTest<AFU extends 
AbstractFileUpload<R, I
         // @formatter:on
         assertEquals(4, fileItems.size());
 
-        final I file = fileItems.get(0);
+        final var file = fileItems.get(0);
         assertHeaders(headerNames, headerValues, file, 0);
 
-        final I field = fileItems.get(1);
+        final var field = fileItems.get(1);
         assertHeaders(headerNames, headerValues, field, 1);
 
-        final I multi0 = fileItems.get(2);
+        final var multi0 = fileItems.get(2);
         assertHeaders(headerNames, headerValues, multi0, 2);
 
-        final I multi1 = fileItems.get(3);
+        final var multi1 = fileItems.get(3);
         assertHeaders(headerNames, headerValues, multi1, 3);
     }
 
@@ -248,8 +247,8 @@ public abstract class AbstractFileUploadTest<AFU extends 
AbstractFileUpload<R, I
     @Test
     public void testFILEUPLOAD62() throws IOException {
         // @formatter:off
-        final String contentType = "multipart/form-data; boundary=AaB03x";
-        final String request =
+        final var contentType = "multipart/form-data; boundary=AaB03x";
+        final var request =
             "--AaB03x\r\n" +
             "content-disposition: form-data; name=\"field1\"\r\n" +
             "\r\n" +
@@ -272,17 +271,17 @@ public abstract class AbstractFileUploadTest<AFU extends 
AbstractFileUpload<R, I
             "--BbC04y--\r\n" +
             "--AaB03x--";
         // @formatter:on
-        final List<I> fileItems = parseUpload(upload, 
request.getBytes(StandardCharsets.US_ASCII), contentType);
+        final var fileItems = parseUpload(upload, 
request.getBytes(StandardCharsets.US_ASCII), contentType);
         assertEquals(3, fileItems.size());
-        final I item0 = fileItems.get(0);
+        final var item0 = fileItems.get(0);
         assertEquals("field1", item0.getFieldName());
         assertNull(item0.getName());
         assertEquals("Joe Blow", new String(item0.get()));
-        final I item1 = fileItems.get(1);
+        final var item1 = fileItems.get(1);
         assertEquals("pics", item1.getFieldName());
         assertEquals("file1.txt", item1.getName());
         assertEquals("... contents of file1.txt ...", new String(item1.get()));
-        final I item2 = fileItems.get(2);
+        final var item2 = fileItems.get(2);
         assertEquals("pics", item2.getFieldName());
         assertEquals("file2.gif", item2.getName());
         assertEquals("...contents of file2.gif...", new String(item2.get()));
@@ -296,7 +295,7 @@ public abstract class AbstractFileUploadTest<AFU extends 
AbstractFileUpload<R, I
     @Test
     public void testFoldedHeaders() throws IOException {
         // @formatter:off
-        final List<I> fileItems = parseUpload(upload, "-----1234\r\n" +
+        final var fileItems = parseUpload(upload, "-----1234\r\n" +
                 "Content-Disposition: form-data; name=\"file\"; 
filename=\"foo.tab\"\r\n" +
                 "Content-Type: text/whatever\r\n" +
                 "\r\n" +
@@ -320,24 +319,24 @@ public abstract class AbstractFileUploadTest<AFU extends 
AbstractFileUpload<R, I
         // @formatter:on
         assertEquals(4, fileItems.size());
 
-        final I file = fileItems.get(0);
+        final var file = fileItems.get(0);
         assertEquals("file", file.getFieldName());
         assertFalse(file.isFormField());
         assertEquals("This is the content of the file\n", file.getString());
         assertEquals("text/whatever", file.getContentType());
         assertEquals("foo.tab", file.getName());
 
-        final I field = fileItems.get(1);
+        final var field = fileItems.get(1);
         assertEquals("field", field.getFieldName());
         assertTrue(field.isFormField());
         assertEquals("fieldValue", field.getString());
 
-        final I multi0 = fileItems.get(2);
+        final var multi0 = fileItems.get(2);
         assertEquals("multi", multi0.getFieldName());
         assertTrue(multi0.isFormField());
         assertEquals("value1", multi0.getString());
 
-        final I multi1 = fileItems.get(3);
+        final var multi1 = fileItems.get(3);
         assertEquals("multi", multi1.getFieldName());
         assertTrue(multi1.isFormField());
         assertEquals("value2", multi1.getString());
@@ -351,7 +350,7 @@ public abstract class AbstractFileUploadTest<AFU extends 
AbstractFileUpload<R, I
      */
     @Test
     public void testIE5MacBug() throws FileUploadException {
-        final List<I> fileItems = parseUpload(upload,
+        final var fileItems = parseUpload(upload,
         // @formatter:off
                 "-----1234\r\n" +
                 "Content-Disposition: form-data; name=\"field1\"\r\n" +
@@ -374,22 +373,22 @@ public abstract class AbstractFileUploadTest<AFU extends 
AbstractFileUpload<R, I
 
         assertEquals(4, fileItems.size());
 
-        final I field1 = fileItems.get(0);
+        final var field1 = fileItems.get(0);
         assertEquals("field1", field1.getFieldName());
         assertTrue(field1.isFormField());
         assertEquals("fieldValue", field1.getString());
 
-        final I submitX = fileItems.get(1);
+        final var submitX = fileItems.get(1);
         assertEquals("submitName.x", submitX.getFieldName());
         assertTrue(submitX.isFormField());
         assertEquals("42", submitX.getString());
 
-        final I submitY = fileItems.get(2);
+        final var submitY = fileItems.get(2);
         assertEquals("submitName.y", submitY.getFieldName());
         assertTrue(submitY.isFormField());
         assertEquals("21", submitY.getString());
 
-        final I field2 = fileItems.get(3);
+        final var field2 = fileItems.get(3);
         assertEquals("field2", field2.getFieldName());
         assertTrue(field2.isFormField());
         assertEquals("fieldValue2", field2.getString());
diff --git 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractFileUploadWrapper.java
 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractFileUploadWrapper.java
index a39bbf00..fd7aeaf3 100644
--- 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractFileUploadWrapper.java
+++ 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractFileUploadWrapper.java
@@ -43,7 +43,7 @@ public abstract class AbstractFileUploadWrapper<AFU extends 
AbstractFileUpload<R
     public abstract List<I> parseUpload(final AFU upload, final byte[] bytes, 
final String contentType) throws FileUploadException;
 
     public List<I> parseUpload(final AFU upload, final String content) throws 
FileUploadException {
-        final byte[] bytes = content.getBytes(StandardCharsets.US_ASCII);
+        final var bytes = content.getBytes(StandardCharsets.US_ASCII);
         return parseUpload(upload, bytes, Constants.CONTENT_TYPE);
     }
 
diff --git 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractProgressListenerTest.java
 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractProgressListenerTest.java
index 801fa6cc..637906a8 100644
--- 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractProgressListenerTest.java
+++ 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractProgressListenerTest.java
@@ -21,7 +21,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
 
 import org.junit.jupiter.api.Test;
@@ -72,22 +71,22 @@ public abstract class AbstractProgressListenerTest<AFU 
extends AbstractFileUploa
     }
 
     protected void runTest(final int itemCount, final long contentLength, 
final R request) throws FileUploadException, IOException {
-        final AFU upload = newFileUpload();
-        final ProgressListenerImpl listener = new 
ProgressListenerImpl(contentLength, itemCount);
+        final var upload = newFileUpload();
+        final var listener = new ProgressListenerImpl(contentLength, 
itemCount);
         upload.setProgressListener(listener);
-        final FileItemInputIterator iter = upload.getItemIterator(request);
-        for (int i = 0; i < itemCount; i++) {
-            final int idxI = i;
-            final FileItemInput fileItemInput = iter.next();
-            try (final InputStream inputStream = 
fileItemInput.getInputStream()) {
-                for (int j = 0; j < 16_384 + i; j++) {
-                    final int idxJ = j;
+        final var iter = upload.getItemIterator(request);
+        for (var i = 0; i < itemCount; i++) {
+            final var idxI = i;
+            final var fileItemInput = iter.next();
+            try (final var inputStream = fileItemInput.getInputStream()) {
+                for (var j = 0; j < 16_384 + i; j++) {
+                    final var idxJ = j;
                     //
                     // This used to be assertEquals((byte) j, (byte) 
istream.read()); but this seems to trigger a bug in JRockit, so we express the 
same like
                     // this:
                     //
-                    final byte b1 = (byte) j;
-                    final byte b2 = (byte) inputStream.read();
+                    final var b1 = (byte) j;
+                    final var b2 = (byte) inputStream.read();
                     assertEquals(b1, b2, () -> String.format("itemCount = %,d, 
i = %,d, j = %,d", itemCount, idxI, idxJ));
                 }
                 assertEquals(-1, inputStream.read());
@@ -104,20 +103,20 @@ public abstract class AbstractProgressListenerTest<AFU 
extends AbstractFileUploa
      */
     @Test
     public void testProgressListener() throws IOException {
-        final int numItems = 512;
-        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        for (int i = 0; i < numItems; i++) {
-            final String header = "-----1234\r\n" + "Content-Disposition: 
form-data; name=\"field" + (i + 1) + "\"\r\n" + "\r\n";
+        final var numItems = 512;
+        final var baos = new ByteArrayOutputStream();
+        for (var i = 0; i < numItems; i++) {
+            final var header = "-----1234\r\n" + "Content-Disposition: 
form-data; name=\"field" + (i + 1) + "\"\r\n" + "\r\n";
             baos.write(header.getBytes(StandardCharsets.US_ASCII));
-            for (int j = 0; j < 16384 + i; j++) {
+            for (var j = 0; j < 16384 + i; j++) {
                 baos.write((byte) j);
             }
             baos.write("\r\n".getBytes(StandardCharsets.US_ASCII));
         }
         baos.write("-----1234--\r\n".getBytes(StandardCharsets.US_ASCII));
-        final byte[] requestBytes = baos.toByteArray();
+        final var requestBytes = baos.toByteArray();
 
-        R request = newMockHttpServletRequest(requestBytes, null, 
Constants.CONTENT_TYPE, null);
+        var request = newMockHttpServletRequest(requestBytes, null, 
Constants.CONTENT_TYPE, null);
         runTest(numItems, requestBytes.length, request);
         request = newMockHttpServletRequest(requestBytes, -1L, 
Constants.CONTENT_TYPE, null);
         runTest(numItems, requestBytes.length, request);
diff --git 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractSizesTest.java
 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractSizesTest.java
index 7ddfef7b..1a22507e 100644
--- 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractSizesTest.java
+++ 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractSizesTest.java
@@ -24,8 +24,6 @@ import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
 
 import org.apache.commons.io.IOUtils;
 import org.junit.jupiter.api.Test;
@@ -49,7 +47,7 @@ public abstract class AbstractSizesTest<AFU extends 
AbstractFileUpload<R, I, F>,
     @Test
     public void testFileSizeLimit() throws IOException {
         // @formatter:off
-        final String request =
+        final var request =
             "-----1234\r\n" +
             "Content-Disposition: form-data; name=\"file\"; 
filename=\"foo.tab\"\r\n" +
             "Content-Type: text/whatever\r\n" +
@@ -59,12 +57,12 @@ public abstract class AbstractSizesTest<AFU extends 
AbstractFileUpload<R, I, F>,
             "-----1234--\r\n";
         // @formatter:on
 
-        AFU upload = newFileUpload();
+        var upload = newFileUpload();
         upload.setFileSizeMax(-1);
-        R req = newMockHttpServletRequest(request, null, null);
-        List<I> fileItems = upload.parseRequest(req);
+        var req = newMockHttpServletRequest(request, null, null);
+        var fileItems = upload.parseRequest(req);
         assertEquals(1, fileItems.size());
-        I item = fileItems.get(0);
+        var item = fileItems.get(0);
         assertEquals("This is the content of the file\n", new 
String(item.get()));
 
         upload = newFileUpload();
@@ -94,7 +92,7 @@ public abstract class AbstractSizesTest<AFU extends 
AbstractFileUpload<R, I, F>,
     @Test
     public void testFileSizeLimitWithFakedContentLength() throws IOException {
         // @formatter:off
-        final String request =
+        final var request =
             "-----1234\r\n" +
             "Content-Disposition: form-data; name=\"file\"; 
filename=\"foo.tab\"\r\n" +
             "Content-Type: text/whatever\r\n" +
@@ -105,12 +103,12 @@ public abstract class AbstractSizesTest<AFU extends 
AbstractFileUpload<R, I, F>,
             "-----1234--\r\n";
         // @formatter:on
 
-        AFU upload = newFileUpload();
+        var upload = newFileUpload();
         upload.setFileSizeMax(-1);
-        R req = newMockHttpServletRequest(request, null, null);
-        List<I> fileItems = upload.parseRequest(req);
+        var req = newMockHttpServletRequest(request, null, null);
+        var fileItems = upload.parseRequest(req);
         assertEquals(1, fileItems.size());
-        I item = fileItems.get(0);
+        var item = fileItems.get(0);
         assertEquals("This is the content of the file\n", new 
String(item.get()));
 
         upload = newFileUpload();
@@ -152,7 +150,7 @@ public abstract class AbstractSizesTest<AFU extends 
AbstractFileUpload<R, I, F>,
     @Test
     public void testMaxSizeLimit() throws IOException {
         // @formatter:off
-        final String request =
+        final var request =
             "-----1234\r\n" +
             "Content-Disposition: form-data; name=\"file1\"; 
filename=\"foo1.tab\"\r\n" +
             "Content-Type: text/whatever\r\n" +
@@ -169,11 +167,11 @@ public abstract class AbstractSizesTest<AFU extends 
AbstractFileUpload<R, I, F>,
             "-----1234--\r\n";
         // @formatter:on
 
-        final AFU upload = newFileUpload();
+        final var upload = newFileUpload();
         upload.setFileSizeMax(-1);
         upload.setSizeMax(200);
 
-        final R req = newMockHttpServletRequest(request, null, null);
+        final var req = newMockHttpServletRequest(request, null, null);
         try {
             upload.parseRequest(req);
             fail("Expected exception.");
@@ -185,7 +183,7 @@ public abstract class AbstractSizesTest<AFU extends 
AbstractFileUpload<R, I, F>,
     @Test
     public void testMaxSizeLimitUnknownContentLength() throws IOException {
         // @formatter:off
-        final String request =
+        final var request =
             "-----1234\r\n" +
             "Content-Disposition: form-data; name=\"file1\"; 
filename=\"foo1.tab\"\r\n" +
             "Content-Type: text/whatever\r\n" +
@@ -202,7 +200,7 @@ public abstract class AbstractSizesTest<AFU extends 
AbstractFileUpload<R, I, F>,
             "-----1234--\r\n";
         // @formatter:on
 
-        final AFU upload = newFileUpload();
+        final var upload = newFileUpload();
         upload.setFileSizeMax(-1);
         upload.setSizeMax(300);
 
@@ -210,19 +208,19 @@ public abstract class AbstractSizesTest<AFU extends 
AbstractFileUpload<R, I, F>,
         // set the read limit to 10 to simulate a "real" stream
         // otherwise the buffer would be immediately filled
 
-        final R req = newMockHttpServletRequest(request, -1L, 10);
+        final var req = newMockHttpServletRequest(request, -1L, 10);
 
-        final FileItemInputIterator it = upload.getItemIterator(req);
+        final var it = upload.getItemIterator(req);
         assertTrue(it.hasNext());
 
-        final FileItemInput item = it.next();
+        final var item = it.next();
         assertFalse(item.isFormField());
         assertEquals("file1", item.getFieldName());
         assertEquals("foo1.tab", item.getName());
 
         {
-            try (final ByteArrayOutputStream baos = new 
ByteArrayOutputStream();
-                    final InputStream stream = item.getInputStream()) {
+            try (final var baos = new ByteArrayOutputStream();
+                    final var stream = item.getInputStream()) {
                 IOUtils.copy(stream, baos);
             }
 
@@ -233,9 +231,9 @@ public abstract class AbstractSizesTest<AFU extends 
AbstractFileUpload<R, I, F>,
         assertTrue(it.hasNext());
 
         assertThrows(FileUploadException.class, () -> {
-            final FileItemInput item2 = it.next();
-            try (final ByteArrayOutputStream baos = new 
ByteArrayOutputStream();
-                    final InputStream stream = item2.getInputStream()) {
+            final var item2 = it.next();
+            try (final var baos = new ByteArrayOutputStream();
+                    final var stream = item2.getInputStream()) {
                 IOUtils.copy(stream, baos);
             }
         });
diff --git 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractStreamingTest.java
 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractStreamingTest.java
index b02edeb2..791f4ed9 100644
--- 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractStreamingTest.java
+++ 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/AbstractStreamingTest.java
@@ -28,7 +28,6 @@ import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.InvalidPathException;
-import java.util.Iterator;
 import java.util.List;
 
 import org.junit.jupiter.api.Test;
@@ -60,17 +59,17 @@ public abstract class AbstractStreamingTest<AFU extends 
AbstractFileUpload<R, I,
     protected abstract F newDiskFileItemFactory();
 
     protected byte[] newRequest() throws IOException {
-        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        try (final OutputStreamWriter osw = new OutputStreamWriter(baos, 
StandardCharsets.US_ASCII)) {
-            int add = 16;
-            int num = 0;
-            for (int i = 0; i < 16384; i += add) {
+        final var baos = new ByteArrayOutputStream();
+        try (final var osw = new OutputStreamWriter(baos, 
StandardCharsets.US_ASCII)) {
+            var add = 16;
+            var num = 0;
+            for (var i = 0; i < 16384; i += add) {
                 if (++add == 32) {
                     add = 16;
                 }
                 osw.write(getHeader("field" + (num++)));
                 osw.flush();
-                for (int j = 0; j < i; j++) {
+                for (var j = 0; j < i; j++) {
                     baos.write((byte) j);
                 }
                 osw.write("\r\n");
@@ -83,8 +82,8 @@ public abstract class AbstractStreamingTest<AFU extends 
AbstractFileUpload<R, I,
     protected abstract C newServletRequestContext(final R request);
 
     protected byte[] newShortRequest() throws IOException {
-        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        try (final OutputStreamWriter osw = new OutputStreamWriter(baos, 
StandardCharsets.US_ASCII)) {
+        final var baos = new ByteArrayOutputStream();
+        try (final var osw = new OutputStreamWriter(baos, 
StandardCharsets.US_ASCII)) {
             osw.write(getHeader("field"));
             osw.write("123");
             osw.write("\r\n");
@@ -98,21 +97,21 @@ public abstract class AbstractStreamingTest<AFU extends 
AbstractFileUpload<R, I,
     }
 
     protected List<I> parseUpload(final InputStream inputStream, final int 
length) throws FileUploadException {
-        final String contentType = "multipart/form-data; boundary=---1234";
+        final var contentType = "multipart/form-data; boundary=---1234";
 
-        final AFU upload = newFileUpload();
+        final var upload = newFileUpload();
         upload.setFileItemFactory(newDiskFileItemFactory());
-        final R request = newMockHttpServletRequest(inputStream, length, 
contentType, -1);
+        final var request = newMockHttpServletRequest(inputStream, length, 
contentType, -1);
 
         return upload.parseRequest(newServletRequestContext(request));
     }
 
     protected FileItemInputIterator parseUpload(final int length, final 
InputStream inputStream) throws FileUploadException, IOException {
-        final String contentType = "multipart/form-data; boundary=---1234";
+        final var contentType = "multipart/form-data; boundary=---1234";
 
-        final AFU upload = newFileUpload();
+        final var upload = newFileUpload();
         upload.setFileItemFactory(newDiskFileItemFactory());
-        final R request = newMockHttpServletRequest(inputStream, length, 
contentType, -1);
+        final var request = newMockHttpServletRequest(inputStream, length, 
contentType, -1);
 
         return upload.getItemIterator(newServletRequestContext(request));
     }
@@ -124,20 +123,20 @@ public abstract class AbstractStreamingTest<AFU extends 
AbstractFileUpload<R, I,
      */
     @Test
     public void testFileUpload() throws IOException {
-        final byte[] request = newRequest();
-        final List<I> fileItems = parseUpload(request);
-        final Iterator<I> fileIter = fileItems.iterator();
-        int add = 16;
-        int num = 0;
-        for (int i = 0; i < 16384; i += add) {
+        final var request = newRequest();
+        final var fileItems = parseUpload(request);
+        final var fileIter = fileItems.iterator();
+        var add = 16;
+        var num = 0;
+        for (var i = 0; i < 16384; i += add) {
             if (++add == 32) {
                 add = 16;
             }
-            final I item = fileIter.next();
+            final var item = fileIter.next();
             assertEquals("field" + (num++), item.getFieldName());
-            final byte[] bytes = item.get();
+            final var bytes = item.get();
             assertEquals(i, bytes.length);
-            for (int j = 0; j < i; j++) {
+            for (var j = 0; j < i; j++) {
                 assertEquals((byte) j, bytes[j]);
             }
         }
@@ -151,9 +150,9 @@ public abstract class AbstractStreamingTest<AFU extends 
AbstractFileUpload<R, I,
      */
     @Test
     public void testFILEUPLOAD135() throws IOException {
-        final byte[] request = newShortRequest();
-        final ByteArrayInputStream bais = new ByteArrayInputStream(request);
-        final List<I> fileItems = parseUpload(new InputStream() {
+        final var request = newShortRequest();
+        final var bais = new ByteArrayInputStream(request);
+        final var fileItems = parseUpload(new InputStream() {
             @Override
             public int read() throws IOException {
                 return bais.read();
@@ -165,11 +164,11 @@ public abstract class AbstractStreamingTest<AFU extends 
AbstractFileUpload<R, I,
             }
 
         }, request.length);
-        final Iterator<I> fileIter = fileItems.iterator();
+        final var fileIter = fileItems.iterator();
         assertTrue(fileIter.hasNext());
-        final I item = fileIter.next();
+        final var item = fileIter.next();
         assertEquals("field", item.getFieldName());
-        final byte[] bytes = item.get();
+        final var bytes = item.get();
         assertEquals(3, bytes.length);
         assertEquals((byte) '1', bytes[0]);
         assertEquals((byte) '2', bytes[1]);
@@ -184,8 +183,8 @@ public abstract class AbstractStreamingTest<AFU extends 
AbstractFileUpload<R, I,
      */
     @Test
     public void testFileUploadException() throws IOException {
-        final byte[] request = newRequest();
-        final byte[] invalidRequest = new byte[request.length - 11];
+        final var request = newRequest();
+        final var invalidRequest = new byte[request.length - 11];
         System.arraycopy(request, 0, invalidRequest, 0, request.length - 11);
         try {
             parseUpload(invalidRequest);
@@ -202,9 +201,9 @@ public abstract class AbstractStreamingTest<AFU extends 
AbstractFileUpload<R, I,
      */
     @Test
     public void testInvalidFileNameException() throws IOException {
-        final String fileName = "foo.exe\u0000.png";
+        final var fileName = "foo.exe\u0000.png";
         // @formatter:off
-        final String request =
+        final var request =
             "-----1234\r\n" +
             "Content-Disposition: form-data; name=\"file\"; filename=\"" + 
fileName + "\"\r\n" +
             "Content-Type: text/whatever\r\n" +
@@ -225,10 +224,10 @@ public abstract class AbstractStreamingTest<AFU extends 
AbstractFileUpload<R, I,
             "value2\r\n" +
             "-----1234--\r\n";
         // @formatter:on
-        final byte[] reqBytes = request.getBytes(StandardCharsets.US_ASCII);
+        final var reqBytes = request.getBytes(StandardCharsets.US_ASCII);
 
-        final FileItemInputIterator fileItemIter = 
parseUpload(reqBytes.length, new ByteArrayInputStream(reqBytes));
-        final FileItemInput fileItemInput = fileItemIter.next();
+        final var fileItemIter = parseUpload(reqBytes.length, new 
ByteArrayInputStream(reqBytes));
+        final var fileItemInput = fileItemIter.next();
         try {
             fileItemInput.getName();
             fail("Expected exception");
@@ -257,7 +256,7 @@ public abstract class AbstractStreamingTest<AFU extends 
AbstractFileUpload<R, I,
      */
     @Test
     public void testIOException() throws IOException {
-        final byte[] request = newRequest();
+        final var request = newRequest();
         final InputStream stream = new FilterInputStream(new 
ByteArrayInputStream(request)) {
             private int num;
 
@@ -271,8 +270,8 @@ public abstract class AbstractStreamingTest<AFU extends 
AbstractFileUpload<R, I,
 
             @Override
             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();
+                for (var i = 0; i < length; i++) {
+                    final var res = read();
                     if (res == -1) {
                         return i == 0 ? -1 : i;
                     }
diff --git 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/DiskFileItemFactoryTest.java
 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/DiskFileItemFactoryTest.java
index 5780f993..0a1c0083 100644
--- 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/DiskFileItemFactoryTest.java
+++ 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/DiskFileItemFactoryTest.java
@@ -21,7 +21,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertSame;
 
 import 
org.apache.commons.fileupload2.core.FileItemFactory.AbstractFileItemBuilder;
-import org.apache.commons.fileupload2.core.DiskFileItem.Builder;
 import org.junit.jupiter.api.Test;
 
 /**
@@ -31,13 +30,13 @@ public class DiskFileItemFactoryTest {
 
     @Test
     void testHeaders() {
-        final DiskFileItemFactory factory = 
DiskFileItemFactory.builder().get();
-        final Builder fileItemBuilder = factory.fileItemBuilder();
+        final var factory = DiskFileItemFactory.builder().get();
+        final var fileItemBuilder = factory.fileItemBuilder();
         assertNotNull(fileItemBuilder.getFileItemHeaders());
-        final DiskFileItem fileItem = fileItemBuilder.get();
+        final var fileItem = fileItemBuilder.get();
         assertNotNull(fileItem.getHeaders(), "Missing default headers 
(empty)");
         assertFalse(fileItem.getHeaders().getHeaderNames().hasNext());
-        final FileItemHeaders fileItemHeaders = 
AbstractFileItemBuilder.newFileItemHeaders();
+        final var fileItemHeaders = 
AbstractFileItemBuilder.newFileItemHeaders();
         assertNotNull(fileItemHeaders);
         fileItem.setHeaders(fileItemHeaders);
         assertSame(fileItemHeaders, fileItem.getHeaders());
diff --git 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/DiskFileItemSerializeTest.java
 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/DiskFileItemSerializeTest.java
index b4f31065..0b6822fe 100644
--- 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/DiskFileItemSerializeTest.java
+++ 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/DiskFileItemSerializeTest.java
@@ -25,7 +25,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.ObjectOutputStream;
-import java.io.OutputStream;
 import java.nio.file.FileVisitResult;
 import java.nio.file.Files;
 import java.nio.file.InvalidPathException;
@@ -66,7 +65,7 @@ public class DiskFileItemSerializeTest {
         assertNotNull(origBytes, "origBytes must not be null");
         assertNotNull(newBytes, "newBytes must not be null");
         assertEquals(origBytes.length, newBytes.length, text + " byte[] 
length");
-        for (int i = 0; i < origBytes.length; i++) {
+        for (var i = 0; i < origBytes.length; i++) {
             assertEquals(origBytes[i], newBytes[i], text + " byte[" + i + "]");
         }
     }
@@ -75,9 +74,9 @@ public class DiskFileItemSerializeTest {
      * Create content bytes of a specified size.
      */
     private byte[] createContentBytes(final int size) {
-        final StringBuilder buffer = new StringBuilder(size);
+        final var buffer = new StringBuilder(size);
         byte count = 0;
-        for (int i = 0; i < size; i++) {
+        for (var i = 0; i < size; i++) {
             buffer.append(count + "");
             count++;
             if (count > 9) {
@@ -105,7 +104,7 @@ public class DiskFileItemSerializeTest {
                 .get();
         // @formatter:on
         // @formatter:off
-        final DiskFileItem item = factory.fileItemBuilder()
+        final var item = factory.fileItemBuilder()
                 .setFieldName("textField")
                 .setContentType(TEXT_CONTENT_TYPE)
                 .setFormField(true)
@@ -113,7 +112,7 @@ public class DiskFileItemSerializeTest {
                 .get();
         // @formatter:on
 
-        try (OutputStream os = item.getOutputStream()) {
+        try (var os = item.getOutputStream()) {
             os.write(contentBytes);
         }
         return item;
@@ -130,8 +129,8 @@ public class DiskFileItemSerializeTest {
      * Serializes.
      */
     private ByteArrayOutputStream serialize(final Object target) throws 
IOException {
-        try (final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                final ObjectOutputStream oos = new ObjectOutputStream(baos)) {
+        try (final var baos = new ByteArrayOutputStream();
+                final var oos = new ObjectOutputStream(baos)) {
             oos.writeObject(target);
             oos.flush();
             return baos;
@@ -170,8 +169,8 @@ public class DiskFileItemSerializeTest {
     @Test
     public void testAboveThreshold() throws IOException {
         // Create the FileItem
-        final byte[] testFieldValueBytes = createContentBytes(THRESHOLD + 1);
-        final DiskFileItem item = createFileItem(testFieldValueBytes);
+        final var testFieldValueBytes = createContentBytes(THRESHOLD + 1);
+        final var item = createFileItem(testFieldValueBytes);
 
         // Check state is as expected
         assertFalse(item.isInMemory(), "Initial: in memory");
@@ -190,7 +189,7 @@ public class DiskFileItemSerializeTest {
     @Test
     public void testBelowThreshold() throws IOException {
         // Create the FileItem
-        final byte[] testFieldValueBytes = createContentBytes(THRESHOLD - 1);
+        final var testFieldValueBytes = createContentBytes(THRESHOLD - 1);
         testInMemoryObject(testFieldValueBytes);
     }
 
@@ -210,7 +209,7 @@ public class DiskFileItemSerializeTest {
      * Helper method to test creation of a field when a repository is used.
      */
     private void testInMemoryObject(final byte[] testFieldValueBytes, final 
Path repository) throws IOException {
-        final DiskFileItem item = createFileItem(testFieldValueBytes, 
repository);
+        final var item = createFileItem(testFieldValueBytes, repository);
 
         // Check state is as expected
         assertTrue(item.isInMemory(), "Initial: in memory");
@@ -228,9 +227,9 @@ public class DiskFileItemSerializeTest {
     @Test
     public void testInvalidRepository() throws IOException {
         // Create the FileItem
-        final byte[] testFieldValueBytes = createContentBytes(THRESHOLD);
-        final Path repository = PathUtils.getTempDirectory().resolve("file");
-        final DiskFileItem item = createFileItem(testFieldValueBytes, 
repository);
+        final var testFieldValueBytes = createContentBytes(THRESHOLD);
+        final var repository = PathUtils.getTempDirectory().resolve("file");
+        final var item = createFileItem(testFieldValueBytes, repository);
         assertThrows(IOException.class, () -> deserialize(serialize(item)));
     }
 
@@ -242,7 +241,7 @@ public class DiskFileItemSerializeTest {
     @Test
     public void testThreshold() throws IOException {
         // Create the FileItem
-        final byte[] testFieldValueBytes = createContentBytes(THRESHOLD);
+        final var testFieldValueBytes = createContentBytes(THRESHOLD);
         testInMemoryObject(testFieldValueBytes);
     }
 
@@ -254,7 +253,7 @@ public class DiskFileItemSerializeTest {
     @Test
     public void testValidRepository() throws IOException {
         // Create the FileItem
-        final byte[] testFieldValueBytes = createContentBytes(THRESHOLD);
+        final var testFieldValueBytes = createContentBytes(THRESHOLD);
         testInMemoryObject(testFieldValueBytes, REPOSITORY);
     }
 
@@ -262,7 +261,7 @@ public class DiskFileItemSerializeTest {
      * Helper method to test writing item contents to a file.
      */
     private void testWritingToFile(final DiskFileItem item, final byte[] 
testFieldValueBytes) throws IOException {
-        final Path temp = Files.createTempFile("fileupload", null);
+        final var temp = Files.createTempFile("fileupload", null);
         // Note that the file exists and is initially empty;
         // write() must be able to handle that.
         item.write(temp);
diff --git 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/DiskFileItemTest.java
 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/DiskFileItemTest.java
index 474e11f7..2db29cb5 100644
--- 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/DiskFileItemTest.java
+++ 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/DiskFileItemTest.java
@@ -21,7 +21,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertSame;
 
 import 
org.apache.commons.fileupload2.core.FileItemFactory.AbstractFileItemBuilder;
-import org.apache.commons.fileupload2.core.DiskFileItem.Builder;
 import org.junit.jupiter.api.Test;
 
 /**
@@ -31,13 +30,13 @@ public class DiskFileItemTest {
 
     @Test
     void testBuilderHeaders() {
-        final Builder builder = DiskFileItem.builder();
+        final var builder = DiskFileItem.builder();
         assertNotNull(builder.getFileItemHeaders());
-        final DiskFileItem fileItem = builder.get();
+        final var fileItem = builder.get();
         assertNotNull(fileItem.getHeaders(), "Missing default headers 
(empty)");
         assertFalse(fileItem.getHeaders().getHeaderNames().hasNext());
         assertNotNull(fileItem.getHeaders());
-        final FileItemHeaders fileItemHeaders = 
AbstractFileItemBuilder.newFileItemHeaders();
+        final var fileItemHeaders = 
AbstractFileItemBuilder.newFileItemHeaders();
         assertNotNull(fileItemHeaders);
         fileItem.setHeaders(fileItemHeaders);
         assertSame(fileItemHeaders, fileItem.getHeaders());
diff --git 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/FileItemHeadersTest.java
 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/FileItemHeadersTest.java
index 0df11eb7..91cb5caa 100644
--- 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/FileItemHeadersTest.java
+++ 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/FileItemHeadersTest.java
@@ -35,7 +35,7 @@ public class FileItemHeadersTest {
      */
     @Test
     public void testFileItemHeaders() throws Exception {
-        final FileItemHeadersImpl mutableFileItemHeaders = new 
FileItemHeadersImpl();
+        final var mutableFileItemHeaders = new FileItemHeadersImpl();
         mutableFileItemHeaders.addHeader("Content-Disposition", "form-data; 
name=\"FileItem\"; filename=\"file1.txt\"");
         mutableFileItemHeaders.addHeader("Content-Type", "text/plain");
 
@@ -44,7 +44,7 @@ public class FileItemHeadersTest {
         mutableFileItemHeaders.addHeader("TestHeader", "headerValue3");
         mutableFileItemHeaders.addHeader("testheader", "headerValue4");
 
-        final Iterator<String> headerNameIterator = 
mutableFileItemHeaders.getHeaderNames();
+        final var headerNameIterator = mutableFileItemHeaders.getHeaderNames();
         assertEquals("content-disposition", headerNameIterator.next());
         assertEquals("content-type", headerNameIterator.next());
         assertEquals("testheader", headerNameIterator.next());
diff --git 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/MultipartStreamTest.java
 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/MultipartStreamTest.java
index 50de0776..9e98f1bb 100644
--- 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/MultipartStreamTest.java
+++ 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/MultipartStreamTest.java
@@ -33,34 +33,34 @@ public class MultipartStreamTest {
 
     @Test
     public void testSmallBuffer() {
-        final String strData = "foobar";
-        final byte[] contents = strData.getBytes();
+        final var strData = "foobar";
+        final var contents = strData.getBytes();
         final InputStream input = new ByteArrayInputStream(contents);
-        final byte[] boundary = BOUNDARY_TEXT.getBytes();
-        final int iBufSize = 1;
+        final var boundary = BOUNDARY_TEXT.getBytes();
+        final var iBufSize = 1;
         assertThrows(IllegalArgumentException.class, () -> 
MultipartInput.builder().setInputStream(input).setBoundary(boundary).setBufferSize(iBufSize)
                 .setProgressNotifier(new MultipartInput.ProgressNotifier(null, 
contents.length)).get());
     }
 
     @Test
     public void testThreeParamConstructor() throws Exception {
-        final String strData = "foobar";
-        final byte[] contents = strData.getBytes();
+        final var strData = "foobar";
+        final var contents = strData.getBytes();
         final InputStream input = new ByteArrayInputStream(contents);
-        final byte[] boundary = BOUNDARY_TEXT.getBytes();
-        final int iBufSize = boundary.length + 
MultipartInput.BOUNDARY_PREFIX.length + 1;
-        final MultipartInput ms = 
MultipartInput.builder().setInputStream(input).setBoundary(boundary).setBufferSize(iBufSize)
+        final var boundary = BOUNDARY_TEXT.getBytes();
+        final var iBufSize = boundary.length + 
MultipartInput.BOUNDARY_PREFIX.length + 1;
+        final var ms = 
MultipartInput.builder().setInputStream(input).setBoundary(boundary).setBufferSize(iBufSize)
                 .setProgressNotifier(new MultipartInput.ProgressNotifier(null, 
contents.length)).get();
         assertNotNull(ms);
     }
 
     @Test
     public void testTwoParamConstructor() throws Exception {
-        final String strData = "foobar";
-        final byte[] contents = strData.getBytes();
+        final var strData = "foobar";
+        final var contents = strData.getBytes();
         final InputStream input = new ByteArrayInputStream(contents);
-        final byte[] boundary = BOUNDARY_TEXT.getBytes();
-        final MultipartInput ms = 
MultipartInput.builder().setInputStream(input).setBoundary(boundary)
+        final var boundary = BOUNDARY_TEXT.getBytes();
+        final var ms = 
MultipartInput.builder().setInputStream(input).setBoundary(boundary)
                 .setProgressNotifier(new MultipartInput.ProgressNotifier(null, 
contents.length)).get();
         assertNotNull(ms);
     }
diff --git 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/ParameterParserTest.java
 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/ParameterParserTest.java
index bfd26c47..8f927352 100644
--- 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/ParameterParserTest.java
+++ 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/ParameterParserTest.java
@@ -19,8 +19,6 @@ package org.apache.commons.fileupload2.core;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNull;
 
-import java.util.Map;
-
 import org.junit.jupiter.api.Test;
 
 /**
@@ -30,19 +28,19 @@ public class ParameterParserTest {
 
     @Test
     public void testContentTypeParsing() {
-        final String s = "text/plain; Charset=UTF-8";
-        final ParameterParser parser = new ParameterParser();
+        final var s = "text/plain; Charset=UTF-8";
+        final var parser = new ParameterParser();
         parser.setLowerCaseNames(true);
-        final Map<String, String> params = parser.parse(s, ';');
+        final var params = parser.parse(s, ';');
         assertEquals("UTF-8", params.get("charset"));
     }
 
     // See: https://issues.apache.org/jira/browse/FILEUPLOAD-139
     @Test
     public void testFileUpload139() {
-        final ParameterParser parser = new ParameterParser();
-        String s = "Content-type: multipart/form-data , boundary=AaB03x";
-        Map<String, String> params = parser.parse(s, new char[] { ',', ';' });
+        final var parser = new ParameterParser();
+        var s = "Content-type: multipart/form-data , boundary=AaB03x";
+        var params = parser.parse(s, new char[] { ',', ';' });
         assertEquals("AaB03x", params.get("boundary"));
 
         s = "Content-type: multipart/form-data, boundary=AaB03x";
@@ -59,10 +57,10 @@ public class ParameterParserTest {
      */
     @Test
     public void testFileUpload199() {
-        final ParameterParser parser = new ParameterParser();
-        final String s = "Content-Disposition: form-data; name=\"file\"; 
filename=\"=?ISO-8859-"
+        final var parser = new ParameterParser();
+        final var s = "Content-Disposition: form-data; name=\"file\"; 
filename=\"=?ISO-8859-"
                 + "1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?= 
=?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=\"\r\n";
-        final Map<String, String> params = parser.parse(s, new char[] { ',', 
';' });
+        final var params = parser.parse(s, new char[] { ',', ';' });
         assertEquals("If you can read this you understand the example.", 
params.get("filename"));
     }
 
@@ -71,11 +69,11 @@ public class ParameterParserTest {
      */
     @Test
     public void testFileUpload274() {
-        final ParameterParser parser = new ParameterParser();
+        final var parser = new ParameterParser();
 
         // Should parse a UTF-8 charset
-        String s = "Content-Disposition: form-data; " + "name=\"file\"; 
filename*=UTF-8''%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF\r\n";
-        Map<String, String> params = parser.parse(s, new char[] { ',', ';' });
+        var s = "Content-Disposition: form-data; " + "name=\"file\"; 
filename*=UTF-8''%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF\r\n";
+        var params = parser.parse(s, new char[] { ',', ';' });
         assertEquals("\u3053\u3093\u306B\u3061\u306F", 
params.get("filename")); // filename = "こんにちは" in japanese
 
         // Should parse ISO-8859-1 charset
@@ -101,9 +99,9 @@ public class ParameterParserTest {
 
     @Test
     public void testParsing() {
-        String s = "test; test1 =  stuff   ; test2 =  \"stuff; stuff\"; 
test3=\"stuff";
-        final ParameterParser parser = new ParameterParser();
-        Map<String, String> params = parser.parse(s, ';');
+        var s = "test; test1 =  stuff   ; test2 =  \"stuff; stuff\"; 
test3=\"stuff";
+        final var parser = new ParameterParser();
+        var params = parser.parse(s, ';');
         assertNull(params.get("test"));
         assertEquals("stuff", params.get("test1"));
         assertEquals("stuff; stuff", params.get("test2"));
@@ -137,9 +135,9 @@ public class ParameterParserTest {
 
     @Test
     public void testParsingEscapedChars() {
-        String s = "param = \"stuff\\\"; more stuff\"";
-        final ParameterParser parser = new ParameterParser();
-        Map<String, String> params = parser.parse(s, ';');
+        var s = "param = \"stuff\\\"; more stuff\"";
+        final var parser = new ParameterParser();
+        var params = parser.parse(s, ';');
         assertEquals(1, params.size());
         assertEquals("stuff\\\"; more stuff", params.get("param"));
 
diff --git 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/QuotedPrintableDecoderTestCase.java
 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/QuotedPrintableDecoderTestCase.java
index 888b5cf2..1dff0500 100644
--- 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/QuotedPrintableDecoderTestCase.java
+++ 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/QuotedPrintableDecoderTestCase.java
@@ -32,24 +32,24 @@ import org.junit.jupiter.api.Test;
 public final class QuotedPrintableDecoderTestCase {
 
     private static void assertEncoded(final String clearText, final String 
encoded) throws Exception {
-        final byte[] expected = clearText.getBytes(StandardCharsets.US_ASCII);
+        final var expected = clearText.getBytes(StandardCharsets.US_ASCII);
 
-        final ByteArrayOutputStream out = new 
ByteArrayOutputStream(encoded.length());
-        final byte[] encodedData = encoded.getBytes(StandardCharsets.US_ASCII);
+        final var out = new ByteArrayOutputStream(encoded.length());
+        final var encodedData = encoded.getBytes(StandardCharsets.US_ASCII);
         QuotedPrintableDecoder.decode(encodedData, out);
-        final byte[] actual = out.toByteArray();
+        final var 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);
+        final var out = new ByteArrayOutputStream(encoded.length());
+        final var encodedData = encoded.getBytes(StandardCharsets.US_ASCII);
         try {
             QuotedPrintableDecoder.decode(encodedData, out);
             fail("Expected IOException");
         } catch (final IOException e) {
-            final String em = e.getMessage();
+            final var em = e.getMessage();
             assertTrue(em.contains(messageText), "Expected to find " + 
messageText + " in '" + em + "'");
         }
     }
diff --git 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/RFC2231UtilityTestCase.java
 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/RFC2231UtilityTestCase.java
index 567cc5e2..a66bcaa9 100644
--- 
a/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/RFC2231UtilityTestCase.java
+++ 
b/commons-fileupload2-core/src/test/java/org/apache/commons/fileupload2/core/RFC2231UtilityTestCase.java
@@ -58,28 +58,28 @@ public final class RFC2231UtilityTestCase {
 
     @Test
     public void testHasEncodedValue() {
-        final String nameWithAsteriskAtEnd = "paramname*";
+        final var nameWithAsteriskAtEnd = "paramname*";
         assertTrue(RFC2231Utils.hasEncodedValue(nameWithAsteriskAtEnd));
 
-        final String nameWithAsteriskNotAtEnd = "param*name";
+        final var nameWithAsteriskNotAtEnd = "param*name";
         assertFalse(RFC2231Utils.hasEncodedValue(nameWithAsteriskNotAtEnd));
 
-        final String nameWithoutAsterisk = "paramname";
+        final var nameWithoutAsterisk = "paramname";
         assertFalse(RFC2231Utils.hasEncodedValue(nameWithoutAsterisk));
     }
 
     @Test
     public void testStripDelimiter() {
-        final String nameWithAsteriskAtEnd = "paramname*";
+        final var nameWithAsteriskAtEnd = "paramname*";
         assertEquals("paramname", 
RFC2231Utils.stripDelimiter(nameWithAsteriskAtEnd));
 
-        final String nameWithAsteriskNotAtEnd = "param*name";
+        final var nameWithAsteriskNotAtEnd = "param*name";
         assertEquals("param*name", 
RFC2231Utils.stripDelimiter(nameWithAsteriskNotAtEnd));
 
-        final String nameWithTwoAsterisks = "param*name*";
+        final var nameWithTwoAsterisks = "param*name*";
         assertEquals("param*name", 
RFC2231Utils.stripDelimiter(nameWithTwoAsterisks));
 
-        final String nameWithoutAsterisk = "paramname";
+        final var nameWithoutAsterisk = "paramname";
         assertEquals("paramname", 
RFC2231Utils.stripDelimiter(nameWithoutAsterisk));
     }
 }
diff --git 
a/commons-fileupload2-jakarta/src/test/java/org/apache/commons/fileupload2/jakarta/JakartaMockServletHttpRequest.java
 
b/commons-fileupload2-jakarta/src/test/java/org/apache/commons/fileupload2/jakarta/JakartaMockServletHttpRequest.java
index f9f61333..0123dd18 100644
--- 
a/commons-fileupload2-jakarta/src/test/java/org/apache/commons/fileupload2/jakarta/JakartaMockServletHttpRequest.java
+++ 
b/commons-fileupload2-jakarta/src/test/java/org/apache/commons/fileupload2/jakarta/JakartaMockServletHttpRequest.java
@@ -493,7 +493,7 @@ public class JakartaMockServletHttpRequest implements 
HttpServletRequest {
 
     @Override
     public ServletContext getServletContext() {
-        final HttpSession session = getSession();
+        final var session = getSession();
         if (session == null) {
             return null;
         }
diff --git 
a/commons-fileupload2-jakarta/src/test/java/org/apache/commons/fileupload2/jakarta/JakartaServletFileUploadDiskTest.java
 
b/commons-fileupload2-jakarta/src/test/java/org/apache/commons/fileupload2/jakarta/JakartaServletFileUploadDiskTest.java
index ead8273b..da2ec5e7 100644
--- 
a/commons-fileupload2-jakarta/src/test/java/org/apache/commons/fileupload2/jakarta/JakartaServletFileUploadDiskTest.java
+++ 
b/commons-fileupload2-jakarta/src/test/java/org/apache/commons/fileupload2/jakarta/JakartaServletFileUploadDiskTest.java
@@ -21,7 +21,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.nio.charset.StandardCharsets;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.commons.fileupload2.core.AbstractFileUploadTest;
 import org.apache.commons.fileupload2.core.Constants;
@@ -47,7 +46,7 @@ public class JakartaServletFileUploadDiskTest extends 
AbstractFileUploadTest<Jak
     public void parseImpliedUtf8() throws Exception {
         // utf8 encoded form-data without explicit content-type encoding
         // @formatter:off
-        final String text = "-----1234\r\n" +
+        final var text = "-----1234\r\n" +
                 "Content-Disposition: form-data; name=\"utf8Html\"\r\n" +
                 "\r\n" +
                 "Thís ís the coñteñt of the fíle\n" +
@@ -55,16 +54,16 @@ public class JakartaServletFileUploadDiskTest extends 
AbstractFileUploadTest<Jak
                 "-----1234--\r\n";
         // @formatter:on
 
-        final byte[] bytes = text.getBytes(StandardCharsets.UTF_8);
+        final var bytes = text.getBytes(StandardCharsets.UTF_8);
         final HttpServletRequest request = new 
JakartaMockServletHttpRequest(bytes, Constants.CONTENT_TYPE);
         // @formatter:off
-        final DiskFileItemFactory fileItemFactory = 
DiskFileItemFactory.builder()
+        final var fileItemFactory = DiskFileItemFactory.builder()
                 .setCharset(StandardCharsets.UTF_8)
                 .get();
         // @formatter:on
-        final JakartaServletDiskFileUpload upload = new 
JakartaServletDiskFileUpload(fileItemFactory);
-        final List<DiskFileItem> fileItems = upload.parseRequest(request);
-        final DiskFileItem fileItem = fileItems.get(0);
+        final var upload = new JakartaServletDiskFileUpload(fileItemFactory);
+        final var fileItems = upload.parseRequest(request);
+        final var fileItem = fileItems.get(0);
         assertTrue(fileItem.getString().contains("coñteñt"), 
fileItem.getString());
     }
 
@@ -74,7 +73,7 @@ public class JakartaServletFileUploadDiskTest extends 
AbstractFileUploadTest<Jak
     @Test
     public void parseParameterMap() throws Exception {
         // @formatter:off
-        final String text = "-----1234\r\n" +
+        final var text = "-----1234\r\n" +
                       "Content-Disposition: form-data; name=\"file\"; 
filename=\"foo.tab\"\r\n" +
                       "Content-Type: text/whatever\r\n" +
                       "\r\n" +
@@ -94,11 +93,11 @@ public class JakartaServletFileUploadDiskTest extends 
AbstractFileUploadTest<Jak
                       "value2\r\n" +
                       "-----1234--\r\n";
         // @formatter:on
-        final byte[] bytes = text.getBytes(StandardCharsets.US_ASCII);
+        final var bytes = text.getBytes(StandardCharsets.US_ASCII);
         final HttpServletRequest request = new 
JakartaMockServletHttpRequest(bytes, Constants.CONTENT_TYPE);
 
-        final JakartaServletDiskFileUpload upload = new 
JakartaServletDiskFileUpload();
-        final Map<String, List<DiskFileItem>> mappedParameters = 
upload.parseParameterMap(request);
+        final var upload = new JakartaServletDiskFileUpload();
+        final var mappedParameters = upload.parseParameterMap(request);
         assertTrue(mappedParameters.containsKey("file"));
         assertEquals(1, mappedParameters.get("file").size());
 
diff --git 
a/commons-fileupload2-jakarta/src/test/java/org/apache/commons/fileupload2/jakarta/JakartaServletFileUploadTest.java
 
b/commons-fileupload2-jakarta/src/test/java/org/apache/commons/fileupload2/jakarta/JakartaServletFileUploadTest.java
index d542d670..ff16b7d3 100644
--- 
a/commons-fileupload2-jakarta/src/test/java/org/apache/commons/fileupload2/jakarta/JakartaServletFileUploadTest.java
+++ 
b/commons-fileupload2-jakarta/src/test/java/org/apache/commons/fileupload2/jakarta/JakartaServletFileUploadTest.java
@@ -21,7 +21,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.nio.charset.StandardCharsets;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.commons.fileupload2.core.AbstractFileUploadTest;
 import org.apache.commons.fileupload2.core.Constants;
@@ -48,7 +47,7 @@ public class JakartaServletFileUploadTest
     public void parseImpliedUtf8() throws Exception {
         // utf8 encoded form-data without explicit content-type encoding
         // @formatter:off
-        final String text = "-----1234\r\n" +
+        final var text = "-----1234\r\n" +
                 "Content-Disposition: form-data; name=\"utf8Html\"\r\n" +
                 "\r\n" +
                 "Thís ís the coñteñt of the fíle\n" +
@@ -56,16 +55,16 @@ public class JakartaServletFileUploadTest
                 "-----1234--\r\n";
         // @formatter:on
 
-        final byte[] bytes = text.getBytes(StandardCharsets.UTF_8);
+        final var bytes = text.getBytes(StandardCharsets.UTF_8);
         final HttpServletRequest request = new 
JakartaMockServletHttpRequest(bytes, Constants.CONTENT_TYPE);
         // @formatter:off
-        final DiskFileItemFactory fileItemFactory = 
DiskFileItemFactory.builder()
+        final var fileItemFactory = DiskFileItemFactory.builder()
                 .setCharset(StandardCharsets.UTF_8)
                 .get();
         // @formatter:on
-        final JakartaServletFileUpload<DiskFileItem, DiskFileItemFactory> 
upload = new JakartaServletFileUpload<>(fileItemFactory);
-        final List<DiskFileItem> fileItems = upload.parseRequest(request);
-        final DiskFileItem fileItem = fileItems.get(0);
+        final var upload = new JakartaServletFileUpload<>(fileItemFactory);
+        final var fileItems = upload.parseRequest(request);
+        final var fileItem = fileItems.get(0);
         assertTrue(fileItem.getString().contains("coñteñt"), 
fileItem.getString());
     }
 
@@ -75,7 +74,7 @@ public class JakartaServletFileUploadTest
     @Test
     public void parseParameterMap() throws Exception {
         // @formatter:off
-        final String text = "-----1234\r\n" +
+        final var text = "-----1234\r\n" +
                       "Content-Disposition: form-data; name=\"file\"; 
filename=\"foo.tab\"\r\n" +
                       "Content-Type: text/whatever\r\n" +
                       "\r\n" +
@@ -95,11 +94,11 @@ public class JakartaServletFileUploadTest
                       "value2\r\n" +
                       "-----1234--\r\n";
         // @formatter:on
-        final byte[] bytes = text.getBytes(StandardCharsets.US_ASCII);
+        final var bytes = text.getBytes(StandardCharsets.US_ASCII);
         final HttpServletRequest request = new 
JakartaMockServletHttpRequest(bytes, Constants.CONTENT_TYPE);
 
-        final JakartaServletFileUpload<DiskFileItem, DiskFileItemFactory> 
upload = new JakartaServletFileUpload<>(DiskFileItemFactory.builder().get());
-        final Map<String, List<DiskFileItem>> mappedParameters = 
upload.parseParameterMap(request);
+        final var upload = new 
JakartaServletFileUpload<>(DiskFileItemFactory.builder().get());
+        final var mappedParameters = upload.parseParameterMap(request);
         assertTrue(mappedParameters.containsKey("file"));
         assertEquals(1, mappedParameters.get("file").size());
 
diff --git 
a/commons-fileupload2-javax/src/test/java/org/apache/commons/fileupload2/javax/JavaxHttpServletRequestFactory.java
 
b/commons-fileupload2-javax/src/test/java/org/apache/commons/fileupload2/javax/JavaxHttpServletRequestFactory.java
index a9f5b004..b77fe505 100644
--- 
a/commons-fileupload2-javax/src/test/java/org/apache/commons/fileupload2/javax/JavaxHttpServletRequestFactory.java
+++ 
b/commons-fileupload2-javax/src/test/java/org/apache/commons/fileupload2/javax/JavaxHttpServletRequestFactory.java
@@ -23,25 +23,25 @@ import 
org.apache.commons.fileupload2.core.AbstractFileUpload;
 final class JavaxHttpServletRequestFactory {
 
     public static HttpServletRequest 
createHttpServletRequestWithNullContentType() {
-        final byte[] requestData = "foobar".getBytes();
+        final var requestData = "foobar".getBytes();
         return new JavaxMockHttpServletRequest(requestData, null);
     }
 
     static public HttpServletRequest createInvalidHttpServletRequest() {
-        final byte[] requestData = "foobar".getBytes();
+        final var requestData = "foobar".getBytes();
         return new JavaxMockHttpServletRequest(requestData, 
AbstractFileUpload.MULTIPART_FORM_DATA);
     }
 
     public static HttpServletRequest createValidHttpServletRequest(final 
String[] strFileNames) {
         // TODO Provide a real implementation.
 
-        final StringBuilder sbRequestData = new StringBuilder();
+        final var sbRequestData = new StringBuilder();
 
         for (final String strFileName : strFileNames) {
             sbRequestData.append(strFileName);
         }
 
-        final byte[] requestData = sbRequestData.toString().getBytes();
+        final var requestData = sbRequestData.toString().getBytes();
 
         return new JavaxMockHttpServletRequest(requestData, 
AbstractFileUpload.MULTIPART_FORM_DATA);
     }
diff --git 
a/commons-fileupload2-javax/src/test/java/org/apache/commons/fileupload2/javax/JavaxServletFileUploadDiskTest.java
 
b/commons-fileupload2-javax/src/test/java/org/apache/commons/fileupload2/javax/JavaxServletFileUploadDiskTest.java
index 75a327ee..93cd93a6 100644
--- 
a/commons-fileupload2-javax/src/test/java/org/apache/commons/fileupload2/javax/JavaxServletFileUploadDiskTest.java
+++ 
b/commons-fileupload2-javax/src/test/java/org/apache/commons/fileupload2/javax/JavaxServletFileUploadDiskTest.java
@@ -23,9 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 
@@ -51,7 +49,7 @@ public class JavaxServletFileUploadDiskTest extends 
AbstractFileUploadTest<Javax
     public void parseImpliedUtf8() throws Exception {
         // utf8 encoded form-data without explicit content-type encoding
         // @formatter:off
-        final String text = "-----1234\r\n" +
+        final var text = "-----1234\r\n" +
                 "Content-Disposition: form-data; name=\"utf8Html\"\r\n" +
                 "\r\n" +
                 "Thís ís the coñteñt of the fíle\n" +
@@ -59,16 +57,16 @@ public class JavaxServletFileUploadDiskTest extends 
AbstractFileUploadTest<Javax
                 "-----1234--\r\n";
         // @formatter:on
 
-        final byte[] bytes = text.getBytes(StandardCharsets.UTF_8);
+        final var bytes = text.getBytes(StandardCharsets.UTF_8);
         final HttpServletRequest request = new 
JavaxMockHttpServletRequest(bytes, Constants.CONTENT_TYPE);
         // @formatter:off
-        final DiskFileItemFactory fileItemFactory = 
DiskFileItemFactory.builder()
+        final var fileItemFactory = DiskFileItemFactory.builder()
                 .setCharset(StandardCharsets.UTF_8)
                 .get();
         // @formatter:on
-        final JavaxServletFileUpload<DiskFileItem, DiskFileItemFactory> upload 
= new JavaxServletFileUpload<>(fileItemFactory);
-        final List<DiskFileItem> fileItems = upload.parseRequest(request);
-        final DiskFileItem fileItem = fileItems.get(0);
+        final var upload = new JavaxServletFileUpload<>(fileItemFactory);
+        final var fileItems = upload.parseRequest(request);
+        final var fileItem = fileItems.get(0);
         assertTrue(fileItem.getString().contains("coñteñt"), 
fileItem.getString());
     }
 
@@ -78,7 +76,7 @@ public class JavaxServletFileUploadDiskTest extends 
AbstractFileUploadTest<Javax
     @Test
     public void parseParameterMap() throws Exception {
         // @formatter:off
-        final String text = "-----1234\r\n" +
+        final var text = "-----1234\r\n" +
                       "Content-Disposition: form-data; name=\"file\"; 
filename=\"foo.tab\"\r\n" +
                       "Content-Type: text/whatever\r\n" +
                       "\r\n" +
@@ -98,11 +96,11 @@ public class JavaxServletFileUploadDiskTest extends 
AbstractFileUploadTest<Javax
                       "value2\r\n" +
                       "-----1234--\r\n";
         // @formatter:on
-        final byte[] bytes = text.getBytes(StandardCharsets.US_ASCII);
+        final var bytes = text.getBytes(StandardCharsets.US_ASCII);
         final HttpServletRequest request = new 
JavaxMockHttpServletRequest(bytes, Constants.CONTENT_TYPE);
 
-        final JavaxServletFileUpload<DiskFileItem, DiskFileItemFactory> upload 
= new JavaxServletFileUpload<>(DiskFileItemFactory.builder().get());
-        final Map<String, List<DiskFileItem>> mappedParameters = 
upload.parseParameterMap(request);
+        final var upload = new 
JavaxServletFileUpload<>(DiskFileItemFactory.builder().get());
+        final var mappedParameters = upload.parseParameterMap(request);
         assertTrue(mappedParameters.containsKey("file"));
         assertEquals(1, mappedParameters.get("file").size());
 
@@ -125,35 +123,35 @@ public class JavaxServletFileUploadDiskTest extends 
AbstractFileUploadTest<Javax
     @Override
     @Test
     public void testFileUpload() throws IOException, FileUploadException {
-        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        int add = 16;
-        int num = 0;
-        for (int i = 0; i < 16384; i += add) {
+        final var baos = new ByteArrayOutputStream();
+        var add = 16;
+        var num = 0;
+        for (var i = 0; i < 16384; i += add) {
             if (++add == 32) {
                 add = 16;
             }
-            final String header = "-----1234\r\n" + "Content-Disposition: 
form-data; name=\"field" + (num++) + "\"\r\n" + "\r\n";
+            final var header = "-----1234\r\n" + "Content-Disposition: 
form-data; name=\"field" + (num++) + "\"\r\n" + "\r\n";
             baos.write(header.getBytes(StandardCharsets.US_ASCII));
-            for (int j = 0; j < i; j++) {
+            for (var j = 0; j < i; j++) {
                 baos.write((byte) j);
             }
             baos.write("\r\n".getBytes(StandardCharsets.US_ASCII));
         }
         baos.write("-----1234--\r\n".getBytes(StandardCharsets.US_ASCII));
 
-        final List<DiskFileItem> fileItems = parseUpload(new 
JavaxServletDiskFileUpload(), baos.toByteArray());
-        final Iterator<DiskFileItem> fileIter = fileItems.iterator();
+        final var fileItems = parseUpload(new JavaxServletDiskFileUpload(), 
baos.toByteArray());
+        final var fileIter = fileItems.iterator();
         add = 16;
         num = 0;
-        for (int i = 0; i < 16384; i += add) {
+        for (var i = 0; i < 16384; i += add) {
             if (++add == 32) {
                 add = 16;
             }
-            final DiskFileItem item = fileIter.next();
+            final var item = fileIter.next();
             assertEquals("field" + (num++), item.getFieldName());
-            final byte[] bytes = item.get();
+            final var bytes = item.get();
             assertEquals(i, bytes.length);
-            for (int j = 0; j < i; j++) {
+            for (var j = 0; j < i; j++) {
                 assertEquals((byte) j, bytes[j]);
             }
         }
diff --git 
a/commons-fileupload2-javax/src/test/java/org/apache/commons/fileupload2/javax/JavaxServletFileUploadTest.java
 
b/commons-fileupload2-javax/src/test/java/org/apache/commons/fileupload2/javax/JavaxServletFileUploadTest.java
index 88c79aa4..1d813a7c 100644
--- 
a/commons-fileupload2-javax/src/test/java/org/apache/commons/fileupload2/javax/JavaxServletFileUploadTest.java
+++ 
b/commons-fileupload2-javax/src/test/java/org/apache/commons/fileupload2/javax/JavaxServletFileUploadTest.java
@@ -23,9 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 
@@ -52,7 +50,7 @@ public class JavaxServletFileUploadTest
     public void parseImpliedUtf8() throws Exception {
         // utf8 encoded form-data without explicit content-type encoding
         // @formatter:off
-        final String text = "-----1234\r\n" +
+        final var text = "-----1234\r\n" +
                 "Content-Disposition: form-data; name=\"utf8Html\"\r\n" +
                 "\r\n" +
                 "Thís ís the coñteñt of the fíle\n" +
@@ -60,16 +58,16 @@ public class JavaxServletFileUploadTest
                 "-----1234--\r\n";
         // @formatter:on
 
-        final byte[] bytes = text.getBytes(StandardCharsets.UTF_8);
+        final var bytes = text.getBytes(StandardCharsets.UTF_8);
         final HttpServletRequest request = new 
JavaxMockHttpServletRequest(bytes, Constants.CONTENT_TYPE);
         // @formatter:off
-        final DiskFileItemFactory fileItemFactory = 
DiskFileItemFactory.builder()
+        final var fileItemFactory = DiskFileItemFactory.builder()
                 .setCharset(StandardCharsets.UTF_8)
                 .get();
         // @formatter:on
-        final JavaxServletFileUpload<DiskFileItem, DiskFileItemFactory> upload 
= new JavaxServletFileUpload<>(fileItemFactory);
-        final List<DiskFileItem> fileItems = upload.parseRequest(request);
-        final DiskFileItem fileItem = fileItems.get(0);
+        final var upload = new JavaxServletFileUpload<>(fileItemFactory);
+        final var fileItems = upload.parseRequest(request);
+        final var fileItem = fileItems.get(0);
         assertTrue(fileItem.getString().contains("coñteñt"), 
fileItem.getString());
     }
 
@@ -79,7 +77,7 @@ public class JavaxServletFileUploadTest
     @Test
     public void parseParameterMap() throws Exception {
         // @formatter:off
-        final String text = "-----1234\r\n" +
+        final var text = "-----1234\r\n" +
                       "Content-Disposition: form-data; name=\"file\"; 
filename=\"foo.tab\"\r\n" +
                       "Content-Type: text/whatever\r\n" +
                       "\r\n" +
@@ -99,11 +97,11 @@ public class JavaxServletFileUploadTest
                       "value2\r\n" +
                       "-----1234--\r\n";
         // @formatter:on
-        final byte[] bytes = text.getBytes(StandardCharsets.US_ASCII);
+        final var bytes = text.getBytes(StandardCharsets.US_ASCII);
         final HttpServletRequest request = new 
JavaxMockHttpServletRequest(bytes, Constants.CONTENT_TYPE);
 
-        final JavaxServletFileUpload<DiskFileItem, DiskFileItemFactory> upload 
= new JavaxServletFileUpload<>(DiskFileItemFactory.builder().get());
-        final Map<String, List<DiskFileItem>> mappedParameters = 
upload.parseParameterMap(request);
+        final var upload = new 
JavaxServletFileUpload<>(DiskFileItemFactory.builder().get());
+        final var mappedParameters = upload.parseParameterMap(request);
         assertTrue(mappedParameters.containsKey("file"));
         assertEquals(1, mappedParameters.get("file").size());
 
@@ -127,35 +125,35 @@ public class JavaxServletFileUploadTest
     @Override
     @Test
     public void testFileUpload() throws IOException, FileUploadException {
-        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        int add = 16;
-        int num = 0;
-        for (int i = 0; i < 16384; i += add) {
+        final var baos = new ByteArrayOutputStream();
+        var add = 16;
+        var num = 0;
+        for (var i = 0; i < 16384; i += add) {
             if (++add == 32) {
                 add = 16;
             }
-            final String header = "-----1234\r\n" + "Content-Disposition: 
form-data; name=\"field" + (num++) + "\"\r\n" + "\r\n";
+            final var header = "-----1234\r\n" + "Content-Disposition: 
form-data; name=\"field" + (num++) + "\"\r\n" + "\r\n";
             baos.write(header.getBytes(StandardCharsets.US_ASCII));
-            for (int j = 0; j < i; j++) {
+            for (var j = 0; j < i; j++) {
                 baos.write((byte) j);
             }
             baos.write("\r\n".getBytes(StandardCharsets.US_ASCII));
         }
         baos.write("-----1234--\r\n".getBytes(StandardCharsets.US_ASCII));
 
-        final List<DiskFileItem> fileItems = parseUpload(new 
JavaxServletFileUpload<>(DiskFileItemFactory.builder().get()), 
baos.toByteArray());
-        final Iterator<DiskFileItem> fileIter = fileItems.iterator();
+        final var fileItems = parseUpload(new 
JavaxServletFileUpload<>(DiskFileItemFactory.builder().get()), 
baos.toByteArray());
+        final var fileIter = fileItems.iterator();
         add = 16;
         num = 0;
-        for (int i = 0; i < 16384; i += add) {
+        for (var i = 0; i < 16384; i += add) {
             if (++add == 32) {
                 add = 16;
             }
-            final DiskFileItem item = fileIter.next();
+            final var item = fileIter.next();
             assertEquals("field" + (num++), item.getFieldName());
-            final byte[] bytes = item.get();
+            final var bytes = item.get();
             assertEquals(i, bytes.length);
-            for (int j = 0; j < i; j++) {
+            for (var j = 0; j < i; j++) {
                 assertEquals((byte) j, bytes[j]);
             }
         }
diff --git 
a/commons-fileupload2-portlet/src/test/java/org/apache/commons/fileupload2/portlet/JavaxPortletFileUploadTest.java
 
b/commons-fileupload2-portlet/src/test/java/org/apache/commons/fileupload2/portlet/JavaxPortletFileUploadTest.java
index 552de0ed..dd2e465a 100644
--- 
a/commons-fileupload2-portlet/src/test/java/org/apache/commons/fileupload2/portlet/JavaxPortletFileUploadTest.java
+++ 
b/commons-fileupload2-portlet/src/test/java/org/apache/commons/fileupload2/portlet/JavaxPortletFileUploadTest.java
@@ -21,7 +21,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.nio.charset.StandardCharsets;
 import java.util.List;
-import java.util.Map;
 
 import javax.portlet.ActionRequest;
 
@@ -47,7 +46,7 @@ public class JavaxPortletFileUploadTest
     @Test
     public void parseParameterMap() throws Exception {
         // @formatter:off
-        final String text = "-----1234\r\n" +
+        final var text = "-----1234\r\n" +
                       "Content-Disposition: form-data; name=\"file\"; 
filename=\"foo.tab\"\r\n" +
                       "Content-Type: text/whatever\r\n" +
                       "\r\n" +
@@ -67,10 +66,10 @@ public class JavaxPortletFileUploadTest
                       "value2\r\n" +
                       "-----1234--\r\n";
         // @formatter:on
-        final byte[] bytes = text.getBytes(StandardCharsets.US_ASCII);
+        final var bytes = text.getBytes(StandardCharsets.US_ASCII);
         final ActionRequest request = new JavaxPortletMockActionRequest(bytes, 
Constants.CONTENT_TYPE);
 
-        final Map<String, List<DiskFileItem>> mappedParameters = 
upload.parseParameterMap(request);
+        final var mappedParameters = upload.parseParameterMap(request);
         assertTrue(mappedParameters.containsKey("file"));
         assertEquals(1, mappedParameters.get("file").size());
 

Reply via email to