You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2022/06/17 13:03:40 UTC

[tomcat] branch main updated (5870b9a846 -> ce32393c40)

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

markt pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


    from 5870b9a846 Remove main conf file
     new 96f9e0a92e Remove unused code
     new fb096de761 Remove unused code - thanks to UCDetector
     new 01763b4ee7 Remove unused code - thanks to UCDetector
     new e3369f3f93 Remove unused code - Thanks to UCDetector
     new b6f3328471 Reviewed forked code
     new ce32393c40 Fix IDE warning after removing unused code

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


Summary of changes:
 MERGE.txt                                          |   5 +
 TOMCAT-NEXT.txt                                    |   4 +-
 java/org/apache/catalina/connector/Request.java    |   4 +-
 .../dbcp/pool2/BaseKeyedPooledObjectFactory.java   | 124 -----------------
 .../tomcat/dbcp/pool2/BasePooledObjectFactory.java | 105 --------------
 .../dbcp/pool2/KeyedPooledObjectFactory.java       |   1 -
 .../apache/tomcat/util/bcel/classfile/Utility.java |   9 --
 .../apache/tomcat/util/codec/binary/Base64.java    | 155 ---------------------
 .../tomcat/util/codec/binary/BaseNCodec.java       |  88 ------------
 .../http/fileupload/ByteArrayOutputStream.java     |  29 ----
 .../tomcat/util/http/fileupload/FileUpload.java    |  13 --
 .../util/http/fileupload/FileUploadBase.java       |  53 -------
 .../util/http/fileupload/FileUploadException.java  |  10 --
 .../util/http/fileupload/MultipartStream.java      |  21 ---
 .../http/fileupload/servlet/ServletFileUpload.java | 137 ------------------
 .../tomcat/util/http/fileupload/util/Streams.java  |  36 -----
 16 files changed, 8 insertions(+), 786 deletions(-)
 delete mode 100644 java/org/apache/tomcat/dbcp/pool2/BaseKeyedPooledObjectFactory.java
 delete mode 100644 java/org/apache/tomcat/dbcp/pool2/BasePooledObjectFactory.java
 delete mode 100644 java/org/apache/tomcat/util/http/fileupload/servlet/ServletFileUpload.java


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 02/06: Remove unused code - thanks to UCDetector

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit fb096de761254980f779ff99057cd3b055e6459d
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Jun 17 12:29:10 2022 +0100

    Remove unused code - thanks to UCDetector
---
 .../apache/tomcat/util/codec/binary/Base64.java    | 155 ---------------------
 .../tomcat/util/codec/binary/BaseNCodec.java       |  88 ------------
 2 files changed, 243 deletions(-)

diff --git a/java/org/apache/tomcat/util/codec/binary/Base64.java b/java/org/apache/tomcat/util/codec/binary/Base64.java
index 3cd4f1a558..5666e9ba3e 100644
--- a/java/org/apache/tomcat/util/codec/binary/Base64.java
+++ b/java/org/apache/tomcat/util/codec/binary/Base64.java
@@ -16,9 +16,6 @@
  */
 package org.apache.tomcat.util.codec.binary;
 
-import java.math.BigInteger;
-import java.util.Objects;
-
 /**
  * Provides Base64 encoding and decoding as defined by <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>.
  *
@@ -138,20 +135,6 @@ public class Base64 extends BaseNCodec {
     // The private member fields below are used with the new streaming approach, which requires
     // some state be preserved between calls of encode() and decode().
 
-    /**
-     * Decodes Base64 data into octets.
-     * <p>
-     * <b>Note:</b> this method seamlessly handles data encoded in URL-safe or normal mode.
-     * </p>
-     *
-     * @param base64Data
-     *            Byte array containing Base64 data
-     * @return Array containing decoded data.
-     */
-    public static byte[] decodeBase64(final byte[] base64Data) {
-        return decodeBase64(base64Data, 0, base64Data.length);
-    }
-
     public  static byte[] decodeBase64(
             final byte[] base64Data, final int off, final int len) {
         return new Base64().decode(base64Data, off, len);
@@ -177,29 +160,6 @@ public class Base64 extends BaseNCodec {
     }
 
     // Implementation of integer encoding used for crypto
-    /**
-     * Decodes a byte64-encoded integer according to crypto standards such as W3C's XML-Signature.
-     *
-     * @param pArray
-     *            a byte array containing base64 character data
-     * @return A BigInteger
-     * @since 1.4
-     */
-    public static BigInteger decodeInteger(final byte[] pArray) {
-        return new BigInteger(1, decodeBase64(pArray));
-    }
-
-    /**
-     * Encodes binary data using the base64 algorithm but does not chunk the output.
-     *
-     * @param binaryData
-     *            binary data to encode
-     * @return byte[] containing Base64 characters in their UTF-8 representation.
-     */
-    public static byte[] encodeBase64(final byte[] binaryData) {
-        return encodeBase64(binaryData, false);
-    }
-
     /**
      * Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks.
      *
@@ -269,17 +229,6 @@ public class Base64 extends BaseNCodec {
         return b64.encode(binaryData);
     }
 
-    /**
-     * Encodes binary data using the base64 algorithm and chunks the encoded output into 76 character blocks
-     *
-     * @param binaryData
-     *            binary data to encode
-     * @return Base64 characters chunked in 76 character blocks
-     */
-    public static byte[] encodeBase64Chunked(final byte[] binaryData) {
-        return encodeBase64(binaryData, true);
-    }
-
     /**
      * Encodes binary data using the base64 algorithm but does not chunk the output.
      *
@@ -295,19 +244,6 @@ public class Base64 extends BaseNCodec {
         return StringUtils.newStringUsAscii(encodeBase64(binaryData, false));
     }
 
-    /**
-     * Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The
-     * url-safe variation emits - and _ instead of + and / characters.
-     * <b>Note: no padding is added.</b>
-     * @param binaryData
-     *            binary data to encode
-     * @return byte[] containing Base64 characters in their UTF-8 representation.
-     * @since 1.4
-     */
-    public static byte[] encodeBase64URLSafe(final byte[] binaryData) {
-        return encodeBase64(binaryData, false, true);
-    }
-
     /**
      * Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The
      * url-safe variation emits - and _ instead of + and / characters.
@@ -321,97 +257,6 @@ public class Base64 extends BaseNCodec {
         return StringUtils.newStringUsAscii(encodeBase64(binaryData, false, true));
     }
 
-    /**
-     * Encodes to a byte64-encoded integer according to crypto standards such as W3C's XML-Signature.
-     *
-     * @param bigInteger
-     *            a BigInteger
-     * @return A byte array containing base64 character data
-     * @throws NullPointerException
-     *             if null is passed in
-     * @since 1.4
-     */
-    public static byte[] encodeInteger(final BigInteger bigInteger) {
-        Objects.requireNonNull(bigInteger,sm.getString("base64.nullEncodeParameter"));
-        return encodeBase64(toIntegerBytes(bigInteger), false);
-    }
-
-    /**
-     * Returns whether or not the {@code octet} is in the base 64 alphabet.
-     *
-     * @param octet
-     *            The value to test
-     * @return {@code true} if the value is defined in the the base 64 alphabet, {@code false} otherwise.
-     * @since 1.4
-     */
-    public static boolean isBase64(final byte octet) {
-        return octet == PAD_DEFAULT || (octet >= 0 && octet < STANDARD_DECODE_TABLE.length && STANDARD_DECODE_TABLE[octet] != -1);
-    }
-
-    /**
-     * Tests a given byte array to see if it contains only valid characters within the Base64 alphabet. Currently the
-     * method treats whitespace as valid.
-     *
-     * @param arrayOctet
-     *            byte array to test
-     * @return {@code true} if all bytes are valid characters in the Base64 alphabet or if the byte array is empty;
-     *         {@code false}, otherwise
-     * @since 1.5
-     */
-    public static boolean isBase64(final byte[] arrayOctet) {
-        for (final byte element : arrayOctet) {
-            if (!isBase64(element) && !isWhiteSpace(element)) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    /**
-     * Tests a given String to see if it contains only valid characters within the Base64 alphabet. Currently the
-     * method treats whitespace as valid.
-     *
-     * @param base64
-     *            String to test
-     * @return {@code true} if all characters in the String are valid characters in the Base64 alphabet or if
-     *         the String is empty; {@code false}, otherwise
-     *  @since 1.5
-     */
-    public static boolean isBase64(final String base64) {
-        return isBase64(StringUtils.getBytesUtf8(base64));
-    }
-
-    /**
-     * Returns a byte-array representation of a {@code BigInteger} without sign bit.
-     *
-     * @param bigInt
-     *            {@code BigInteger} to be converted
-     * @return a byte array representation of the BigInteger parameter
-     */
-    static byte[] toIntegerBytes(final BigInteger bigInt) {
-        int bitlen = bigInt.bitLength();
-        // round bitlen
-        bitlen = ((bitlen + 7) >> 3) << 3;
-        final byte[] bigBytes = bigInt.toByteArray();
-
-        if (((bigInt.bitLength() % 8) != 0) && (((bigInt.bitLength() / 8) + 1) == (bitlen / 8))) {
-            return bigBytes;
-        }
-        // set up params for copying everything but sign bit
-        int startSrc = 0;
-        int len = bigBytes.length;
-
-        // if bigInt is exactly byte-aligned, just skip signbit in copy
-        if ((bigInt.bitLength() % 8) == 0) {
-            startSrc = 1;
-            len--;
-        }
-        final int startDst = bitlen / 8 - len; // to pad w/ nulls as per spec
-        final byte[] resizedBytes = new byte[bitlen / 8];
-        System.arraycopy(bigBytes, startSrc, resizedBytes, startDst, len);
-        return resizedBytes;
-    }
-
     /**
      * Validates whether decoding the final trailing character is possible in the context
      * of the set of possible base 64 values.
diff --git a/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java b/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
index 6ca10acaae..6c1a7be4a3 100644
--- a/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
+++ b/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
@@ -114,18 +114,6 @@ public abstract class BaseNCodec {
      */
     public static final int MIME_CHUNK_SIZE = 76;
 
-    /**
-     * PEM chunk size per RFC 1421 section 4.3.2.4.
-     *
-     * <p>
-     * The {@value} character limit does not count the trailing CRLF, but counts all other characters, including any
-     * equal signs.
-     * </p>
-     *
-     * @see <a href="http://tools.ietf.org/html/rfc1421">RFC 1421 section 4.3.2.4</a>
-     */
-    public static final int PEM_CHUNK_SIZE = 64;
-
     private static final int DEFAULT_BUFFER_RESIZE_FACTOR = 2;
 
     /**
@@ -205,36 +193,6 @@ public abstract class BaseNCodec {
             MAX_BUFFER_SIZE;
     }
 
-    /**
-     * Gets a copy of the chunk separator per RFC 2045 section 2.1.
-     *
-     * @return the chunk separator
-     * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045 section 2.1</a>
-     * @since 1.15
-     */
-    public static byte[] getChunkSeparator() {
-        return CHUNK_SEPARATOR.clone();
-    }
-
-    /**
-     * Checks if a byte value is whitespace or not.
-     * Whitespace is taken to mean: space, tab, CR, LF
-     * @param byteToCheck
-     *            the byte to check
-     * @return true if byte is whitespace, false otherwise
-     */
-    protected static boolean isWhiteSpace(final byte byteToCheck) {
-        switch (byteToCheck) {
-            case ' ' :
-            case '\n' :
-            case '\r' :
-            case '\t' :
-                return true;
-            default :
-                return false;
-        }
-    }
-
     /**
      * Increases our buffer by the {@link #DEFAULT_BUFFER_RESIZE_FACTOR}.
      * @param context the context to be used
@@ -428,24 +386,11 @@ public abstract class BaseNCodec {
      * @param pArray a byte array containing binary data
      * @return String containing only character data in the appropriate alphabet.
      * @since 1.5
-     * This is a duplicate of {@link #encodeToString(byte[])}; it was merged during refactoring.
     */
     public String encodeAsString(final byte[] pArray){
         return StringUtils.newStringUtf8(encode(pArray));
     }
 
-    /**
-     * Encodes a byte[] containing binary data, into a String containing characters in the Base-N alphabet.
-     * Uses UTF8 encoding.
-     *
-     * @param pArray
-     *            a byte array containing binary data
-     * @return A String containing only Base-N character data
-     */
-    public String encodeToString(final byte[] pArray) {
-        return StringUtils.newStringUtf8(encode(pArray));
-    }
-
     /**
      * Ensure that the buffer has room for {@code size} bytes
      *
@@ -515,39 +460,6 @@ public abstract class BaseNCodec {
      */
     protected abstract boolean isInAlphabet(byte value);
 
-    /**
-     * Tests a given byte array to see if it contains only valid characters within the alphabet.
-     * The method optionally treats whitespace and pad as valid.
-     *
-     * @param arrayOctet byte array to test
-     * @param allowWSPad if {@code true}, then whitespace and PAD are also allowed
-     *
-     * @return {@code true} if all bytes are valid characters in the alphabet or if the byte array is empty;
-     *         {@code false}, otherwise
-     */
-    public boolean isInAlphabet(final byte[] arrayOctet, final boolean allowWSPad) {
-        for (final byte octet : arrayOctet) {
-            if (!isInAlphabet(octet) &&
-                    (!allowWSPad || (octet != pad) && !isWhiteSpace(octet))) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    /**
-     * Tests a given String to see if it contains only valid characters within the alphabet.
-     * The method treats whitespace and PAD as valid.
-     *
-     * @param basen String to test
-     * @return {@code true} if all characters in the String are valid characters in the alphabet or if
-     *         the String is empty; {@code false}, otherwise
-     * @see #isInAlphabet(byte[], boolean)
-     */
-    public boolean isInAlphabet(final String basen) {
-        return isInAlphabet(StringUtils.getBytesUtf8(basen), true);
-    }
-
     /**
      * Extracts buffered data into the provided byte[] array, starting at position bPos, up to a maximum of bAvail
      * bytes. Returns how many bytes were actually extracted.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 03/06: Remove unused code - thanks to UCDetector

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 01763b4ee77e7751f40deb0920f116e65b0b5a91
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Jun 17 12:46:38 2022 +0100

    Remove unused code - thanks to UCDetector
---
 MERGE.txt                                          |   3 +
 java/org/apache/catalina/connector/Request.java    |   4 +-
 .../http/fileupload/ByteArrayOutputStream.java     |  29 -----
 .../tomcat/util/http/fileupload/FileUpload.java    |  13 --
 .../util/http/fileupload/FileUploadBase.java       |  53 --------
 .../util/http/fileupload/FileUploadException.java  |  10 --
 .../util/http/fileupload/MultipartStream.java      |  21 ----
 .../http/fileupload/servlet/ServletFileUpload.java | 137 ---------------------
 .../tomcat/util/http/fileupload/util/Streams.java  |  36 ------
 9 files changed, 5 insertions(+), 301 deletions(-)

diff --git a/MERGE.txt b/MERGE.txt
index e1403d4853..fd18d82c80 100644
--- a/MERGE.txt
+++ b/MERGE.txt
@@ -33,6 +33,7 @@ the patch file has been applied and committed
 
 BCEL
 ----
+Unused code is removed
 Sub-tree:
 src/main/java/org/apache/bcel
 The SHA1 ID / tag for the most recent commit to be merged to Tomcat is:
@@ -40,6 +41,7 @@ The SHA1 ID / tag for the most recent commit to be merged to Tomcat is:
 
 Codec
 -----
+Unused code is removed
 Sub-tree:
 src/main/java/org/apache/commons/codec
 The SHA1 ID / tag for the most recent commit to be merged to Tomcat is:
@@ -48,6 +50,7 @@ Note: Only classes required for Base64 encoding/decoding. The rest are removed.
 
 FileUpload
 ----------
+Unused code is removed
 Sub-tree:
 src/main/java/org/apache/commons/fileupload2
 The SHA1 ID / tag for the most recent commit to be merged to Tomcat is:
diff --git a/java/org/apache/catalina/connector/Request.java b/java/org/apache/catalina/connector/Request.java
index 72f308aa99..40475e8fc5 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -106,10 +106,10 @@ import org.apache.tomcat.util.http.Parameters.FailReason;
 import org.apache.tomcat.util.http.ServerCookie;
 import org.apache.tomcat.util.http.ServerCookies;
 import org.apache.tomcat.util.http.fileupload.FileItem;
+import org.apache.tomcat.util.http.fileupload.FileUpload;
 import org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory;
 import org.apache.tomcat.util.http.fileupload.impl.InvalidContentTypeException;
 import org.apache.tomcat.util.http.fileupload.impl.SizeException;
-import org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload;
 import org.apache.tomcat.util.http.fileupload.servlet.ServletRequestContext;
 import org.apache.tomcat.util.http.parser.AcceptLanguage;
 import org.apache.tomcat.util.http.parser.Upgrade;
@@ -2865,7 +2865,7 @@ public class Request implements HttpServletRequest {
             }
             factory.setSizeThreshold(mce.getFileSizeThreshold());
 
-            ServletFileUpload upload = new ServletFileUpload();
+            FileUpload upload = new FileUpload();
             upload.setFileItemFactory(factory);
             upload.setFileSizeMax(mce.getMaxFileSize());
             upload.setSizeMax(mce.getMaxRequestSize());
diff --git a/java/org/apache/tomcat/util/http/fileupload/ByteArrayOutputStream.java b/java/org/apache/tomcat/util/http/fileupload/ByteArrayOutputStream.java
index 5cc26df6ef..aaee63f112 100644
--- a/java/org/apache/tomcat/util/http/fileupload/ByteArrayOutputStream.java
+++ b/java/org/apache/tomcat/util/http/fileupload/ByteArrayOutputStream.java
@@ -17,7 +17,6 @@
 package org.apache.tomcat.util.http.fileupload;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.List;
@@ -167,34 +166,6 @@ public class ByteArrayOutputStream extends OutputStream {
         count++;
     }
 
-    /**
-     * Writes the entire contents of the specified input stream to this
-     * byte stream. Bytes from the input stream are read directly into the
-     * internal buffers of this streams.
-     *
-     * @param in the input stream to read from
-     * @return total number of bytes read from the input stream
-     *         (and written to this stream)
-     * @throws IOException if an I/O error occurs while reading the input stream
-     * @since 1.4
-     */
-    public synchronized int write(final InputStream in) throws IOException {
-        int readCount = 0;
-        int inBufferPos = count - filledBufferSum;
-        int n = in.read(currentBuffer, inBufferPos, currentBuffer.length - inBufferPos);
-        while (n != -1) {
-            readCount += n;
-            inBufferPos += n;
-            count += n;
-            if (inBufferPos == currentBuffer.length) {
-                needNewBuffer(currentBuffer.length);
-                inBufferPos = 0;
-            }
-            n = in.read(currentBuffer, inBufferPos, currentBuffer.length - inBufferPos);
-        }
-        return readCount;
-    }
-
     /**
      * Closing a {@code ByteArrayOutputStream} has no effect. The methods in
      * this class can be called after the stream has been closed without
diff --git a/java/org/apache/tomcat/util/http/fileupload/FileUpload.java b/java/org/apache/tomcat/util/http/fileupload/FileUpload.java
index f0cfebcf08..06846f18d6 100644
--- a/java/org/apache/tomcat/util/http/fileupload/FileUpload.java
+++ b/java/org/apache/tomcat/util/http/fileupload/FileUpload.java
@@ -48,23 +48,10 @@ public class FileUpload
      * A factory must be
      * configured, using {@code setFileItemFactory()}, before attempting
      * to parse requests.
-     *
-     * @see #FileUpload(FileItemFactory)
      */
     public FileUpload() {
     }
 
-    /**
-     * Constructs an instance of this class which uses the supplied factory to
-     * create {@code FileItem} instances.
-     *
-     * @see #FileUpload()
-     * @param fileItemFactory The factory to use for creating file items.
-     */
-    public FileUpload(final FileItemFactory fileItemFactory) {
-        this.fileItemFactory = fileItemFactory;
-    }
-
     // ----------------------------------------------------- Property accessors
 
     /**
diff --git a/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java b/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
index 7d678c24d8..45c4fb93c0 100644
--- a/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
+++ b/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
@@ -19,7 +19,6 @@ package org.apache.tomcat.util.http.fileupload;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -48,30 +47,6 @@ import org.apache.tomcat.util.http.fileupload.util.Streams;
  */
 public abstract class FileUploadBase {
 
-    // ---------------------------------------------------------- Class methods
-
-    /**
-     * <p>Utility method that determines whether the request contains multipart
-     * content.</p>
-     *
-     * <p><strong>NOTE:</strong>This method will be moved to the
-     * {@code ServletFileUpload} class after the FileUpload 1.1 release.
-     * Unfortunately, since this method is static, it is not possible to
-     * provide its replacement until this method is removed.</p>
-     *
-     * @param ctx The request context to be evaluated. Must be non-null.
-     *
-     * @return {@code true} if the request is multipart;
-     *         {@code false} otherwise.
-     */
-    public static final boolean isMultipartContent(final RequestContext ctx) {
-        final String contentType = ctx.getContentType();
-        if (contentType == null) {
-            return false;
-        }
-        return contentType.toLowerCase(Locale.ENGLISH).startsWith(MULTIPART);
-    }
-
     // ----------------------------------------------------- Manifest constants
 
     /**
@@ -314,34 +289,6 @@ public abstract class FileUploadBase {
         }
     }
 
-    /**
-     * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>
-     * compliant {@code multipart/form-data} stream.
-     *
-     * @param ctx The context for the request to be parsed.
-     *
-     * @return A map of {@code FileItem} instances parsed from the request.
-     *
-     * @throws FileUploadException if there are problems reading/parsing
-     *                             the request or storing files.
-     *
-     * @since 1.3
-     */
-    public Map<String, List<FileItem>> parseParameterMap(final RequestContext ctx)
-            throws FileUploadException {
-        final List<FileItem> items = parseRequest(ctx);
-        final Map<String, List<FileItem>> itemsMap = new HashMap<>(items.size());
-
-        for (final FileItem fileItem : items) {
-            final String fieldName = fileItem.getFieldName();
-            List<FileItem> mappedItems = itemsMap.computeIfAbsent(fieldName, k -> new ArrayList<>());
-
-            mappedItems.add(fileItem);
-        }
-
-        return itemsMap;
-    }
-
     // ------------------------------------------------------ Protected methods
 
     /**
diff --git a/java/org/apache/tomcat/util/http/fileupload/FileUploadException.java b/java/org/apache/tomcat/util/http/fileupload/FileUploadException.java
index 47b8230217..d7a8d11819 100644
--- a/java/org/apache/tomcat/util/http/fileupload/FileUploadException.java
+++ b/java/org/apache/tomcat/util/http/fileupload/FileUploadException.java
@@ -52,14 +52,4 @@ public class FileUploadException extends IOException {
     public FileUploadException(final String msg, final Throwable cause) {
         super(msg, cause);
     }
-
-    /**
-     * Creates a new {@code FileUploadException} with the given
-     * cause.
-     *
-     * @param cause The exceptions cause.
-     */
-    public FileUploadException(final Throwable cause) {
-        super(cause);
-    }
 }
diff --git a/java/org/apache/tomcat/util/http/fileupload/MultipartStream.java b/java/org/apache/tomcat/util/http/fileupload/MultipartStream.java
index ab6e8e58ad..d38eb379d5 100644
--- a/java/org/apache/tomcat/util/http/fileupload/MultipartStream.java
+++ b/java/org/apache/tomcat/util/http/fileupload/MultipartStream.java
@@ -650,27 +650,6 @@ public class MultipartStream {
         return true;
     }
 
-    /**
-     * Searches for a byte of specified value in the {@code buffer},
-     * starting at the specified {@code position}.
-     *
-     * @param value The value to find.
-     * @param pos   The starting position for searching.
-     *
-     * @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++) {
-            if (buffer[i] == value) {
-                return i;
-            }
-        }
-
-        return -1;
-    }
-
     /**
      * Searches for the {@code boundary} in the {@code buffer}
      * region delimited by {@code head} and {@code tail}.
diff --git a/java/org/apache/tomcat/util/http/fileupload/servlet/ServletFileUpload.java b/java/org/apache/tomcat/util/http/fileupload/servlet/ServletFileUpload.java
deleted file mode 100644
index da07201538..0000000000
--- a/java/org/apache/tomcat/util/http/fileupload/servlet/ServletFileUpload.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.util.http.fileupload.servlet;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-import jakarta.servlet.http.HttpServletRequest;
-
-import org.apache.tomcat.util.http.fileupload.FileItem;
-import org.apache.tomcat.util.http.fileupload.FileItemFactory;
-import org.apache.tomcat.util.http.fileupload.FileItemIterator;
-import org.apache.tomcat.util.http.fileupload.FileUpload;
-import org.apache.tomcat.util.http.fileupload.FileUploadBase;
-import org.apache.tomcat.util.http.fileupload.FileUploadException;
-
-
-/**
- * <p>High level API for processing file uploads.</p>
- *
- * <p>This class handles multiple files per single HTML widget, sent using
- * {@code multipart/mixed} encoding type, as specified by
- * <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>.  Use {@link
- * #parseRequest(org.apache.tomcat.util.http.fileupload.RequestContext)} to
- * acquire a list of {@link org.apache.tomcat.util.http.fileupload.FileItem}s
- * associated with a given HTML widget.</p>
- *
- * <p>How the data for individual parts is stored is determined by the factory
- * used to create them; a given part may be in memory, on disk, or somewhere
- * else.</p>
- */
-public class ServletFileUpload extends FileUpload {
-
-    /**
-     * Constant for HTTP POST method.
-     */
-    private static final String POST_METHOD = "POST";
-
-    // ---------------------------------------------------------- Class methods
-
-    /**
-     * Utility method that determines whether the request contains multipart
-     * content.
-     *
-     * @param request The servlet request to be evaluated. Must be non-null.
-     *
-     * @return {@code true} if the request is multipart;
-     *         {@code false} otherwise.
-     */
-    public static final boolean isMultipartContent(
-            final HttpServletRequest request) {
-        if (!POST_METHOD.equalsIgnoreCase(request.getMethod())) {
-            return false;
-        }
-        return FileUploadBase.isMultipartContent(new ServletRequestContext(request));
-    }
-
-    // ----------------------------------------------------------- Constructors
-
-    /**
-     * Constructs an uninitialized instance of this class. A factory must be
-     * configured, using {@code setFileItemFactory()}, before attempting
-     * to parse requests.
-     *
-     * @see FileUpload#FileUpload(FileItemFactory)
-     */
-    public ServletFileUpload() {
-    }
-
-    /**
-     * Constructs an instance of this class which uses the supplied factory to
-     * create {@code FileItem} instances.
-     *
-     * @see FileUpload#FileUpload()
-     * @param fileItemFactory The factory to use for creating file items.
-     */
-    public ServletFileUpload(final FileItemFactory fileItemFactory) {
-        super(fileItemFactory);
-    }
-
-    // --------------------------------------------------------- Public methods
-
-    /**
-     * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>
-     * compliant {@code multipart/form-data} stream.
-     *
-     * @param request The servlet request to be parsed.
-     *
-     * @return A map of {@code FileItem} instances parsed from the request.
-     *
-     * @throws FileUploadException if there are problems reading/parsing
-     *                             the request or storing files.
-     *
-     * @since 1.3
-     */
-    public Map<String, List<FileItem>> parseParameterMap(final HttpServletRequest request)
-            throws FileUploadException {
-        return parseParameterMap(new ServletRequestContext(request));
-    }
-
-    /**
-     * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>
-     * compliant {@code multipart/form-data} stream.
-     *
-     * @param request The servlet request to be parsed.
-     *
-     * @return An iterator to instances of {@code FileItemStream}
-     *         parsed from the request, in the order that they were
-     *         transmitted.
-     *
-     * @throws FileUploadException if there are problems reading/parsing
-     *                             the request or storing files.
-     * @throws IOException An I/O error occurred. This may be a network
-     *   error while communicating with the client or a problem while
-     *   storing the uploaded content.
-     */
-    public FileItemIterator getItemIterator(final HttpServletRequest request)
-    throws FileUploadException, IOException {
-        return super.getItemIterator(new ServletRequestContext(request));
-    }
-
-}
diff --git a/java/org/apache/tomcat/util/http/fileupload/util/Streams.java b/java/org/apache/tomcat/util/http/fileupload/util/Streams.java
index 03c1f90486..5fe3314bce 100644
--- a/java/org/apache/tomcat/util/http/fileupload/util/Streams.java
+++ b/java/org/apache/tomcat/util/http/fileupload/util/Streams.java
@@ -16,7 +16,6 @@
  */
 package org.apache.tomcat.util.http.fileupload.util;
 
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -117,41 +116,6 @@ public final class Streams {
         }
     }
 
-    /**
-     * This convenience method allows to read a
-     * {@link org.apache.tomcat.util.http.fileupload.FileItemStream}'s
-     * content into a string. The platform's default character encoding
-     * is used for converting bytes into characters.
-     *
-     * @param inputStream The input stream to read.
-     * @see #asString(InputStream, String)
-     * @return The streams contents, as a string.
-     * @throws IOException An I/O error occurred.
-     */
-    public static String asString(final InputStream inputStream) throws IOException {
-        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        copy(inputStream, baos, true);
-        return baos.toString();
-    }
-
-    /**
-     * This convenience method allows to read a
-     * {@link org.apache.tomcat.util.http.fileupload.FileItemStream}'s
-     * content into a string, using the given character encoding.
-     *
-     * @param inputStream The input stream to read.
-     * @param encoding The character encoding, typically "UTF-8".
-     * @see #asString(InputStream)
-     * @return The streams contents, as a string.
-     * @throws IOException An I/O error occurred.
-     */
-    public static String asString(final InputStream inputStream, final String encoding)
-            throws IOException {
-        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        copy(inputStream, baos, true);
-        return baos.toString(encoding);
-    }
-
     /**
      * Checks, whether the given file name is valid in the sense,
      * that it doesn't contain any NUL characters. If the file name


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 01/06: Remove unused code

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 96f9e0a92e74b0aa57e4e6a054fc1276c4618659
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Jun 17 12:20:44 2022 +0100

    Remove unused code
---
 java/org/apache/tomcat/util/bcel/classfile/Utility.java | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/java/org/apache/tomcat/util/bcel/classfile/Utility.java b/java/org/apache/tomcat/util/bcel/classfile/Utility.java
index dc0a09bbc1..3c272a7641 100644
--- a/java/org/apache/tomcat/util/bcel/classfile/Utility.java
+++ b/java/org/apache/tomcat/util/bcel/classfile/Utility.java
@@ -61,13 +61,4 @@ final class Utility {
             throw new EOFException();
         }
     }
-
-    static void swallowAttribute(final DataInput file)
-            throws IOException {
-        //file.readUnsignedShort();   // Unused name index
-        skipFully(file, 2);
-        // Length of data in bytes
-        int length = file.readInt();
-        skipFully(file, length);
-    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 06/06: Fix IDE warning after removing unused code

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit ce32393c40e01532b54835f9aeacdfb01f78d64f
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Jun 17 14:02:49 2022 +0100

    Fix IDE warning after removing unused code
---
 java/org/apache/tomcat/dbcp/pool2/KeyedPooledObjectFactory.java | 1 -
 1 file changed, 1 deletion(-)

diff --git a/java/org/apache/tomcat/dbcp/pool2/KeyedPooledObjectFactory.java b/java/org/apache/tomcat/dbcp/pool2/KeyedPooledObjectFactory.java
index 428155d7f9..2ce6cea882 100644
--- a/java/org/apache/tomcat/dbcp/pool2/KeyedPooledObjectFactory.java
+++ b/java/org/apache/tomcat/dbcp/pool2/KeyedPooledObjectFactory.java
@@ -67,7 +67,6 @@ package org.apache.tomcat.dbcp.pool2;
  * </p>
  *
  * @see KeyedObjectPool
- * @see BaseKeyedPooledObjectFactory
  *
  * @param <K> The type of keys managed by this factory.
  * @param <V> Type of element managed by this factory.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 04/06: Remove unused code - Thanks to UCDetector

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit e3369f3f93ac327ea920c5e712f1041589dbe1ff
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Jun 17 14:01:45 2022 +0100

    Remove unused code - Thanks to UCDetector
---
 MERGE.txt                                          |   2 +
 .../dbcp/pool2/BaseKeyedPooledObjectFactory.java   | 124 ---------------------
 .../tomcat/dbcp/pool2/BasePooledObjectFactory.java | 105 -----------------
 3 files changed, 2 insertions(+), 229 deletions(-)

diff --git a/MERGE.txt b/MERGE.txt
index fd18d82c80..61720d0da7 100644
--- a/MERGE.txt
+++ b/MERGE.txt
@@ -62,12 +62,14 @@ Note: Tomcat's copy of fileupload also includes classes copied manually from
 DBCP
 ----
 Pool2
+Unused classes removed
 Sub-tree
 src/main/java/org/apache/commons/pool2
 The SHA1 ID / tag for the most recent commit to be merged to Tomcat is:
 rel/commons-pool-2.11.1 (2021-08-17)
 
 DBCP2
+No unused code removed
 Sub-tree
 src/main/java/org/apache/commons/dbcp2
 src/main/resources/org/apache/commons/dbcp2
diff --git a/java/org/apache/tomcat/dbcp/pool2/BaseKeyedPooledObjectFactory.java b/java/org/apache/tomcat/dbcp/pool2/BaseKeyedPooledObjectFactory.java
deleted file mode 100644
index a9877f12b6..0000000000
--- a/java/org/apache/tomcat/dbcp/pool2/BaseKeyedPooledObjectFactory.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.dbcp.pool2;
-
-/**
- * A base implementation of {@code KeyedPooledObjectFactory}.
- * <p>
- * All operations defined here are essentially no-op's.
- * </p>
- * <p>
- * This class is immutable, and therefore thread-safe.
- * </p>
- *
- * @see KeyedPooledObjectFactory
- *
- * @param <K> The type of keys managed by this factory.
- * @param <V> Type of element managed by this factory.
- *
- * @since 2.0
- */
-public abstract class BaseKeyedPooledObjectFactory<K, V> extends BaseObject
-        implements KeyedPooledObjectFactory<K, V> {
-
-    /**
-     * Reinitialize an instance to be returned by the pool.
-     * <p>
-     * The default implementation is a no-op.
-     * </p>
-     *
-     * @param key the key used when selecting the object
-     * @param p a {@code PooledObject} wrapping the instance to be activated
-     */
-    @Override
-    public void activateObject(final K key, final PooledObject<V> p)
-        throws Exception {
-        // The default implementation is a no-op.
-    }
-
-    /**
-     * Create an instance that can be served by the pool.
-     *
-     * @param key the key used when constructing the object
-     * @return an instance that can be served by the pool
-     *
-     * @throws Exception if there is a problem creating a new instance,
-     *    this will be propagated to the code requesting an object.
-     */
-    public abstract V create(K key)
-        throws Exception;
-
-    /**
-     * Destroy an instance no longer needed by the pool.
-     * <p>
-     * The default implementation is a no-op.
-     * </p>
-     *
-     * @param key the key used when selecting the instance
-     * @param p a {@code PooledObject} wrapping the instance to be destroyed
-     */
-    @Override
-    public void destroyObject(final K key, final PooledObject<V> p)
-        throws Exception {
-        // The default implementation is a no-op.
-    }
-
-    @Override
-    public PooledObject<V> makeObject(final K key) throws Exception {
-        return wrap(create(key));
-    }
-
-    /**
-     * Uninitialize an instance to be returned to the idle object pool.
-     * <p>
-     * The default implementation is a no-op.
-     * </p>
-     *
-     * @param key the key used when selecting the object
-     * @param p a {@code PooledObject} wrapping the instance to be passivated
-     */
-    @Override
-    public void passivateObject(final K key, final PooledObject<V> p)
-        throws Exception {
-        // The default implementation is a no-op.
-    }
-
-    /**
-     * Ensures that the instance is safe to be returned by the pool.
-     * <p>
-     * The default implementation always returns {@code true}.
-     * </p>
-     *
-     * @param key the key used when selecting the object
-     * @param p a {@code PooledObject} wrapping the instance to be validated
-     * @return always {@code true} in the default implementation
-     */
-    @Override
-    public boolean validateObject(final K key, final PooledObject<V> p) {
-        return true;
-    }
-
-    /**
-     * Wrap the provided instance with an implementation of
-     * {@link PooledObject}.
-     *
-     * @param value the instance to wrap
-     *
-     * @return The provided instance, wrapped by a {@link PooledObject}
-     */
-    public abstract PooledObject<V> wrap(V value);
-}
diff --git a/java/org/apache/tomcat/dbcp/pool2/BasePooledObjectFactory.java b/java/org/apache/tomcat/dbcp/pool2/BasePooledObjectFactory.java
deleted file mode 100644
index 3a309f4241..0000000000
--- a/java/org/apache/tomcat/dbcp/pool2/BasePooledObjectFactory.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.dbcp.pool2;
-
-/**
- * A base implementation of {@code PoolableObjectFactory}.
- * <p>
- * All operations defined here are essentially no-op's.
- * <p>
- * This class is immutable, and therefore thread-safe
- *
- * @param <T> Type of element managed in this factory.
- *
- * @see PooledObjectFactory
- * @see BaseKeyedPooledObjectFactory
- *
- * @since 2.0
- */
-public abstract class BasePooledObjectFactory<T> extends BaseObject implements PooledObjectFactory<T> {
-
-    /**
-     *  No-op.
-     *
-     *  @param p ignored
-     */
-    @Override
-    public void activateObject(final PooledObject<T> p) throws Exception {
-        // The default implementation is a no-op.
-    }
-
-    /**
-     * Creates an object instance, to be wrapped in a {@link PooledObject}.
-     * <p>This method <strong>must</strong> support concurrent, multi-threaded
-     * activation.</p>
-     *
-     * @return an instance to be served by the pool
-     *
-     * @throws Exception if there is a problem creating a new instance,
-     *    this will be propagated to the code requesting an object.
-     */
-    public abstract T create() throws Exception;
-
-    /**
-     *  No-op.
-     *
-     *  @param p ignored
-     */
-    @Override
-    public void destroyObject(final PooledObject<T> p)
-        throws Exception  {
-        // The default implementation is a no-op.
-    }
-
-    @Override
-    public PooledObject<T> makeObject() throws Exception {
-        return wrap(create());
-    }
-
-    /**
-     *  No-op.
-     *
-     * @param p ignored
-     */
-    @Override
-    public void passivateObject(final PooledObject<T> p)
-        throws Exception {
-        // The default implementation is a no-op.
-    }
-
-    /**
-     * Always returns {@code true}.
-     *
-     * @param p ignored
-     *
-     * @return {@code true}
-     */
-    @Override
-    public boolean validateObject(final PooledObject<T> p) {
-        return true;
-    }
-
-    /**
-     * Wraps the provided instance with an implementation of
-     * {@link PooledObject}.
-     *
-     * @param obj the instance to wrap
-     *
-     * @return The provided instance, wrapped by a {@link PooledObject}
-     */
-    public abstract PooledObject<T> wrap(T obj);
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 05/06: Reviewed forked code

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit b6f3328471c0ada000f9105dc4807880bb093595
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Jun 17 14:02:11 2022 +0100

    Reviewed forked code
---
 TOMCAT-NEXT.txt | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/TOMCAT-NEXT.txt b/TOMCAT-NEXT.txt
index 437637f921..4a247a7201 100644
--- a/TOMCAT-NEXT.txt
+++ b/TOMCAT-NEXT.txt
@@ -19,8 +19,6 @@ Notes of things to consider for the next major Tomcat release (10.1.x)
 
 Deferred until 10.1.x:
 
- 1. Review code forked from Commons projects and consider removing unused code.
-
- 2. Implement OCSP checks for client certs with NIO/NIO2.
+ 1. Implement OCSP checks for client certs with NIO/NIO2.
     Useful reference:
     https://stackoverflow.com/questions/5161504/ocsp-revocation-on-client-certificate
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org