This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push: new 8d21b9ef4a Update internal fork of Apache Commons FileUpload 8d21b9ef4a is described below commit 8d21b9ef4ae30f6f6474f00a72887338a5b745ac Author: Mark Thomas <ma...@apache.org> AuthorDate: Tue Nov 29 15:20:39 2022 +0000 Update internal fork of Apache Commons FileUpload --- MERGE.txt | 2 +- .../util/http/fileupload/FileUploadBase.java | 2 +- .../util/http/fileupload/MultipartStream.java | 2 +- .../util/http/fileupload/RequestContext.java | 2 +- .../util/http/fileupload/disk/DiskFileItem.java | 40 +++++++--------------- .../http/fileupload/disk/DiskFileItemFactory.java | 2 +- webapps/docs/changelog.xml | 4 +++ 7 files changed, 21 insertions(+), 33 deletions(-) diff --git a/MERGE.txt b/MERGE.txt index f0fa5d7dd5..885bbabe7e 100644 --- a/MERGE.txt +++ b/MERGE.txt @@ -51,7 +51,7 @@ FileUpload Sub-tree: src/main/java/org/apache/commons/fileupload2 The SHA1 ID / tag for the most recent commit to be merged to Tomcat is: -33d2d79230bb851642435821b380904d24752ee1 (2021-09-01) +aa8eff6f04c939fd99834360415b1ddb2f637cb1 (2022-11-29) Note: Tomcat's copy of fileupload also includes classes copied manually from Commons IO. diff --git a/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java b/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java index e159e6a6bf..267a5ae9d1 100644 --- a/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java +++ b/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java @@ -367,7 +367,7 @@ public abstract class FileUploadBase { if (boundaryStr == null) { return null; } - byte[] boundary; + final byte[] boundary; boundary = boundaryStr.getBytes(StandardCharsets.ISO_8859_1); return boundary; } diff --git a/java/org/apache/tomcat/util/http/fileupload/MultipartStream.java b/java/org/apache/tomcat/util/http/fileupload/MultipartStream.java index ab6e8e58ad..137185aa77 100644 --- a/java/org/apache/tomcat/util/http/fileupload/MultipartStream.java +++ b/java/org/apache/tomcat/util/http/fileupload/MultipartStream.java @@ -401,7 +401,7 @@ public class MultipartStream { public boolean readBoundary() throws FileUploadIOException, MalformedStreamException { final byte[] marker = new byte[2]; - boolean nextChunk; + final boolean nextChunk; head += boundaryLength; try { diff --git a/java/org/apache/tomcat/util/http/fileupload/RequestContext.java b/java/org/apache/tomcat/util/http/fileupload/RequestContext.java index 8fb222ce2b..9c00856032 100644 --- a/java/org/apache/tomcat/util/http/fileupload/RequestContext.java +++ b/java/org/apache/tomcat/util/http/fileupload/RequestContext.java @@ -24,7 +24,7 @@ import java.io.InputStream; * interface should be implemented for each type of request that may be * handled by FileUpload, such as servlets and portlets.</p> * - * @since FileUpload 1.1 + * @since 1.1 */ public interface RequestContext { 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 e9a16211e7..228a061de7 100644 --- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java +++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java @@ -55,7 +55,7 @@ import org.apache.tomcat.util.http.fileupload.util.Streams; * <p>Temporary files, which are created for file items, should be * deleted later on.</p> * - * @since FileUpload 1.1 + * @since 1.1 */ public class DiskFileItem implements FileItem { @@ -300,7 +300,7 @@ public class DiskFileItem return cachedContent != null ? cachedContent.clone() : new byte[0]; } - byte[] fileData = new byte[(int) getSize()]; + final byte[] fileData = new byte[(int) getSize()]; try (InputStream fis = Files.newInputStream(dfos.getFile().toPath())) { IOUtils.readFully(fis, fileData); @@ -338,14 +338,14 @@ public class DiskFileItem @Override public String getString() { try { - byte[] rawData = get(); + final byte[] rawData = get(); String charset = getCharSet(); if (charset == null) { charset = defaultCharset; } return new String(rawData, charset); } catch (final IOException e) { - return new String(new byte[0]); + return ""; } } @@ -374,7 +374,7 @@ public class DiskFileItem if (isInMemory()) { try (OutputStream fout = Files.newOutputStream(file.toPath())) { fout.write(get()); - } catch (IOException e) { + } catch (final IOException e) { throw new IOException("Unexpected output data"); } } else { @@ -415,18 +415,18 @@ public class DiskFileItem } /** - * Deletes the underlying storage for a file item, including deleting any - * associated temporary disk file. Although this storage will be deleted - * automatically when the {@code FileItem} instance is garbage - * collected, this method can be used to ensure that this is done at an - * earlier time, thus preserving system resources. + * Deletes the underlying storage for a file item, including deleting any associated temporary disk file. + * This method can be used to ensure that this is done at an earlier time, thus preserving system resources. */ @Override public void delete() { cachedContent = null; final File outputFile = getStoreLocation(); if (outputFile != null && !isInMemory() && outputFile.exists()) { - outputFile.delete(); + if (!outputFile.delete()) { + final String desc = "Cannot delete " + outputFile.toString(); + throw new IllegalStateException(desc, new IOException(desc)); + } } } @@ -436,7 +436,7 @@ public class DiskFileItem * * @return The name of the form field. * - * @see #setFieldName(java.lang.String) + * @see #setFieldName(String) * */ @Override @@ -531,22 +531,6 @@ public class DiskFileItem // ------------------------------------------------------ Protected methods - /** - * Removes the file contents from the temporary storage. - */ - @Override - protected void finalize() throws Throwable { - if (dfos == null || dfos.isInMemory()) { - return; - } - final File outputFile = dfos.getFile(); - - if (outputFile != null && outputFile.exists()) { - outputFile.delete(); - } - super.finalize(); - } - /** * Creates and returns a {@link java.io.File File} representing a uniquely * named temporary file in the configured repository path. The lifetime of 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 6fb8f77deb..f19c5c3af6 100644 --- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java +++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java @@ -54,7 +54,7 @@ import org.apache.tomcat.util.http.fileupload.FileItemFactory; * <p>Temporary files, which are created for file items, should be * deleted later on.</p> * - * @since FileUpload 1.1 + * @since 1.1 */ public class DiskFileItemFactory implements FileItemFactory { diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index cc34efd544..d5fac37a12 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -155,6 +155,10 @@ <update> Update to Commons Daemon 1.3.3. (markt) </update> + <update> + Update the internal fork of Apache Commons FileUpload to aa8eff6 + (2022-11-29, 2.0-SNAPSHOT). (markt) + </update> </changelog> </subsection> </section> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org