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 2023/09/16 09:00:23 UTC

[tomcat] branch 9.0.x updated (0debf210d2 -> 85850d2891)

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

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


    from 0debf210d2 Remove unnecessary @SuppressWarnings
     new 6b31b66171 Improve alignment with Commons FileUpload 1.x
     new e25c07657e Throw original exception
     new 43b882b8a5 Restore the finalize() method
     new 798883192e Better Javadoc / comments
     new 85850d2891 Update changelog

The 5 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:
 .../util/http/fileupload/FileUploadBase.java       |  7 +++---
 .../util/http/fileupload/disk/DiskFileItem.java    | 29 +++++++++++++++-------
 .../http/fileupload/disk/DiskFileItemFactory.java  |  8 +++---
 .../http/fileupload/servlet/ServletFileUpload.java |  1 -
 .../fileupload/servlet/ServletRequestContext.java  |  4 +--
 .../tomcat/util/http/fileupload/util/Streams.java  |  9 +++----
 .../http/fileupload/util/mime/RFC2231Utility.java  | 15 ++++++-----
 webapps/docs/changelog.xml                         | 10 ++++++++
 8 files changed, 49 insertions(+), 34 deletions(-)


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


[tomcat] 03/05: Restore the finalize() method

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

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

commit 43b882b8a577684498ab9b8851aa0427216784f7
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Sep 15 22:53:24 2023 +0100

    Restore the finalize() method
---
 .../tomcat/util/http/fileupload/disk/DiskFileItem.java    | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
index d7cd4798fb..bc2067b24a 100644
--- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
+++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
@@ -531,6 +531,21 @@ public class DiskFileItem
 
     // ------------------------------------------------------ Protected methods
 
+    /**
+     * Removes the file contents from the temporary storage.
+     */
+    @Override
+    protected void finalize() {
+        if (dfos == null || dfos.isInMemory()) {
+            return;
+        }
+        final File outputFile = dfos.getFile();
+
+        if (outputFile != null && outputFile.exists()) {
+            outputFile.delete();
+        }
+    }
+
     /**
      * Creates and returns a {@link java.io.File File} representing a uniquely
      * named temporary file in the configured repository path. The lifetime of


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


[tomcat] 05/05: Update changelog

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

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

commit 85850d2891ff317228c5c9b8f1345dd9bb6c834d
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Sat Sep 16 09:46:37 2023 +0100

    Update changelog
---
 webapps/docs/changelog.xml | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index b2e8edf1c8..deddcd33c5 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -135,6 +135,16 @@
       </fix>
     </changelog>
   </subsection>
+  <subsection name="Other">
+    <changelog>
+      <update>
+        Update the internal fork of Apache Commons FileUpload to 7a8c324
+        (2023-09-16, 1.x-SNAPSHOT). Due to significant refactoring in the 2.x
+        branch requiring additional Commons IO dependencies, Tomcat has switched
+        to tracking the 1.x branch. (markt)
+      </update>
+    </changelog>
+  </subsection>
 </section>
 <section name="Tomcat 9.0.80 (markt)" rtext="2023-08-25">
   <subsection name="Catalina">


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


[tomcat] 02/05: Throw original exception

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

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

commit e25c07657e39ee474c234463d2647594532f4f0d
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Sep 15 22:50:44 2023 +0100

    Throw original exception
---
 java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java | 2 --
 1 file changed, 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
index e8fdb67b9c..d7cd4798fb 100644
--- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
+++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
@@ -377,8 +377,6 @@ public class DiskFileItem
         if (isInMemory()) {
             try (OutputStream fout = Files.newOutputStream(file.toPath())) {
                 fout.write(get());
-            } catch (final IOException e) {
-                throw new IOException("Unexpected output data");
             }
         } else {
             final File outputFile = getStoreLocation();


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


[tomcat] 04/05: Better Javadoc / comments

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

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

commit 798883192ed50ba394e65a53d9a3c1cee0d632cf
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Sep 15 22:54:26 2023 +0100

    Better Javadoc / comments
---
 java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java  | 6 +++---
 .../tomcat/util/http/fileupload/disk/DiskFileItemFactory.java       | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
index bc2067b24a..ad55faa92a 100644
--- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
+++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
@@ -53,8 +53,8 @@ import org.apache.tomcat.util.http.fileupload.util.Streams;
  * {@link #getInputStream()} and process the file without attempting to load
  * it into memory, which may come handy with large files.
  *
- * <p>Temporary files, which are created for file items, should be
- * deleted later on.</p>
+ * <p>Temporary files, which are created for file items, will be deleted when
+ * the associated request is recycled.</p>
  *
  * @since 1.1
  */
@@ -193,7 +193,7 @@ public class DiskFileItem
     public InputStream getInputStream()
         throws IOException {
         if (!isInMemory()) {
-            // Uses old code to avoid JVM bug
+            // Avoid JVM bug
             // https://bz.apache.org/bugzilla/show_bug.cgi?id=65710
             return new FileInputStream(dfos.getFile());
         }
diff --git a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java
index a6bd67e943..6d61c0d351 100644
--- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java
+++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java
@@ -47,12 +47,12 @@ import org.apache.tomcat.util.http.fileupload.FileItemFactory;
  * implementation in an environment with local, untrusted users,
  * {@link #setRepository(File)} MUST be used to configure a repository location
  * that is not publicly writable. In a Servlet container the location identified
- * by the ServletContext attribute {@code java.servlet.context.tempdir}
+ * by the ServletContext attribute {@code javax.servlet.context.tempdir}
  * may be used.
  * </p>
  *
- * <p>Temporary files, which are created for file items, should be
- * deleted later on.</p>
+ * <p>Temporary files, which are created for file items, will be deleted when
+ * the associated request is recycled.</p>
  *
  * @since 1.1
  */


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


[tomcat] 01/05: Improve alignment with Commons FileUpload 1.x

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

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

commit 6b31b66171cf18c4e5feb23b6f123c4001cfc131
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Sep 15 22:43:39 2023 +0100

    Improve alignment with Commons FileUpload 1.x
---
 .../tomcat/util/http/fileupload/FileUploadBase.java       |  7 +++----
 .../tomcat/util/http/fileupload/disk/DiskFileItem.java    |  6 ++----
 .../util/http/fileupload/disk/DiskFileItemFactory.java    |  2 +-
 .../util/http/fileupload/servlet/ServletFileUpload.java   |  1 -
 .../http/fileupload/servlet/ServletRequestContext.java    |  4 +---
 .../apache/tomcat/util/http/fileupload/util/Streams.java  |  9 ++++-----
 .../util/http/fileupload/util/mime/RFC2231Utility.java    | 15 +++++++--------
 7 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java b/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
index 4c61fa718c..c17eb978af 100644
--- a/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
+++ b/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
@@ -221,11 +221,11 @@ public abstract class FileUploadBase {
     }
 
     /**
-     * Sets the maximum number of files allowed per request/
+     * Sets the maximum number of files allowed per request.
      *
      * @param fileCountMax The new limit. {@code -1} means no limit.
      */
-    public void setFileCountMax(long fileCountMax) {
+    public void setFileCountMax(final long fileCountMax) {
         this.fileCountMax = fileCountMax;
     }
 
@@ -560,8 +560,7 @@ public abstract class FileUploadBase {
             return;
         }
         final String headerName = header.substring(0, colonOffset).trim();
-        final String headerValue =
-            header.substring(colonOffset + 1).trim();
+        final String headerValue = header.substring(colonOffset + 1).trim();
         headers.addHeader(headerName, headerValue);
     }
 
diff --git a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
index ccf937c410..e8fdb67b9c 100644
--- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
+++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
@@ -398,8 +398,7 @@ public class DiskFileItem
              * desired file.
              */
             if (file.exists() && !file.delete()) {
-                throw new FileUploadException(
-                        "Cannot write uploaded file to disk!");
+                throw new FileUploadException("Cannot write uploaded file to disk!");
             }
             if (!outputFile.renameTo(file)) {
                 BufferedInputStream in = null;
@@ -588,8 +587,7 @@ public class DiskFileItem
     @Override
     public String toString() {
         return String.format("name=%s, StoreLocation=%s, size=%s bytes, isFormField=%s, FieldName=%s",
-                      getName(), getStoreLocation(), Long.valueOf(getSize()),
-                      Boolean.valueOf(isFormField()), getFieldName());
+                getName(), getStoreLocation(), Long.valueOf(getSize()), Boolean.valueOf(isFormField()), getFieldName());
     }
 
     /**
diff --git a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java
index 43e766e83c..a6bd67e943 100644
--- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java
+++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java
@@ -178,7 +178,7 @@ public class DiskFileItemFactory implements FileItemFactory {
      */
     @Override
     public FileItem createItem(final String fieldName, final String contentType,
-                final boolean isFormField, final String fileName) {
+            final boolean isFormField, final String fileName) {
         final DiskFileItem result = new DiskFileItem(fieldName, contentType,
                 isFormField, fileName, sizeThreshold, repository);
         result.setDefaultCharset(defaultCharset);
diff --git a/java/org/apache/tomcat/util/http/fileupload/servlet/ServletFileUpload.java b/java/org/apache/tomcat/util/http/fileupload/servlet/ServletFileUpload.java
index 268bad8e1b..e2d074c3df 100644
--- a/java/org/apache/tomcat/util/http/fileupload/servlet/ServletFileUpload.java
+++ b/java/org/apache/tomcat/util/http/fileupload/servlet/ServletFileUpload.java
@@ -29,7 +29,6 @@ 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>
  *
diff --git a/java/org/apache/tomcat/util/http/fileupload/servlet/ServletRequestContext.java b/java/org/apache/tomcat/util/http/fileupload/servlet/ServletRequestContext.java
index a23f69360c..d9c01984fe 100644
--- a/java/org/apache/tomcat/util/http/fileupload/servlet/ServletRequestContext.java
+++ b/java/org/apache/tomcat/util/http/fileupload/servlet/ServletRequestContext.java
@@ -24,7 +24,6 @@ import javax.servlet.http.HttpServletRequest;
 import org.apache.tomcat.util.http.fileupload.FileUploadBase;
 import org.apache.tomcat.util.http.fileupload.UploadContext;
 
-
 /**
  * <p>Provides access to the request information needed for a request made to
  * an HTTP servlet.</p>
@@ -110,8 +109,7 @@ public class ServletRequestContext implements UploadContext {
     @Override
     public String toString() {
         return String.format("ContentLength=%s, ContentType=%s",
-                Long.valueOf(this.contentLength()),
-                this.getContentType());
+                Long.valueOf(this.contentLength()), this.getContentType());
     }
 
 }
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..ed83840d90 100644
--- a/java/org/apache/tomcat/util/http/fileupload/util/Streams.java
+++ b/java/org/apache/tomcat/util/http/fileupload/util/Streams.java
@@ -55,10 +55,10 @@ public final class Streams {
      * @param outputStream The output stream, to which data should
      * be written. May be null, in which case the input streams
      * contents are simply discarded.
-     * @param closeOutputStream True guarantees, that
-     * {@link OutputStream#close()} is called on the stream.
-     * False indicates, that only
+     * @param closeOutputStream True guarantees, that {@link OutputStream#close()}
+     * is called on the stream. False indicates, that only
      * {@link OutputStream#flush()} should be called finally.
+     *
      * @return Number of bytes, which have been copied.
      * @throws IOException An I/O error occurred.
      */
@@ -145,8 +145,7 @@ public final class Streams {
      * @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 {
+    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);
diff --git a/java/org/apache/tomcat/util/http/fileupload/util/mime/RFC2231Utility.java b/java/org/apache/tomcat/util/http/fileupload/util/mime/RFC2231Utility.java
index c15bb2027d..8a522a313f 100644
--- a/java/org/apache/tomcat/util/http/fileupload/util/mime/RFC2231Utility.java
+++ b/java/org/apache/tomcat/util/http/fileupload/util/mime/RFC2231Utility.java
@@ -20,13 +20,12 @@ import java.io.ByteArrayOutputStream;
 import java.io.UnsupportedEncodingException;
 /**
  * Utility class to decode/encode character set on HTTP Header fields based on RFC 2231.
- * This implementation adheres to RFC 5987 in particular, which was defined for HTTP headers
- *
+ * This implementation adheres to RFC 5987 in particular, which was defined for HTTP headers.
+ * <p>
  * RFC 5987 builds on RFC 2231, but has lesser scope like
  * <a href="https://tools.ietf.org/html/rfc5987#section-3.2">mandatory charset definition</a>
  * and <a href="https://tools.ietf.org/html/rfc5987#section-4">no parameter continuation</a>
  *
- * <p>
  * @see <a href="https://tools.ietf.org/html/rfc2231">RFC 2231</a>
  * @see <a href="https://tools.ietf.org/html/rfc5987">RFC 5987</a>
  */
@@ -93,15 +92,15 @@ public final class RFC2231Utility {
 
     /**
      * Decode a string of text obtained from a HTTP header as per RFC 2231
-     *
+     * <p>
      * <b>Eg 1.</b> {@code us-ascii'en-us'This%20is%20%2A%2A%2Afun%2A%2A%2A}
      * will be decoded to {@code This is ***fun***}
-     *
+     * <p>
      * <b>Eg 2.</b> {@code iso-8859-1'en'%A3%20rate}
-     * will be decoded to {@code £ rate}.
-     *
+     * will be decoded to {@code £ rate}
+     * <p>
      * <b>Eg 3.</b> {@code UTF-8''%c2%a3%20and%20%e2%82%ac%20rates}
-     * will be decoded to {@code £ and € rates}.
+     * will be decoded to {@code £ and € rates}
      *
      * @param encodedText - Text to be decoded has a format of {@code <charset>'<language>'<encoded_value>}
      * and ASCII only


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