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
The following commit(s) were added to refs/heads/9.0.x by this push:
new 7ee910b0f0 Update internal fork of Apache Commons FileUpload
7ee910b0f0 is described below
commit 7ee910b0f0991677bdd0ac0bd9753e611a9c5be3
Author: Mark Thomas <[email protected]>
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 | 42 +++++++---------------
.../http/fileupload/disk/DiskFileItemFactory.java | 2 +-
.../http/fileupload/util/FileItemHeadersImpl.java | 3 +-
webapps/docs/changelog.xml | 4 +++
8 files changed, 24 insertions(+), 35 deletions(-)
diff --git a/MERGE.txt b/MERGE.txt
index 65f94662ff..ed99e7c447 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 7d678c24d8..248d1c59a4 100644
--- a/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
+++ b/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
@@ -362,7 +362,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 521abaf1da..ccf937c410 100644
--- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
+++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
@@ -56,7 +56,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 {
@@ -301,11 +301,11 @@ 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);
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new UncheckedIOException(e);
}
return fileData;
@@ -341,14 +341,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 "";
}
}
@@ -377,7 +377,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 {
@@ -418,18 +418,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 UncheckedIOException(desc, new IOException(desc));
+ }
}
}
@@ -439,7 +439,7 @@ public class DiskFileItem
*
* @return The name of the form field.
*
- * @see #setFieldName(java.lang.String)
+ * @see #setFieldName(String)
*
*/
@Override
@@ -534,22 +534,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/java/org/apache/tomcat/util/http/fileupload/util/FileItemHeadersImpl.java
b/java/org/apache/tomcat/util/http/fileupload/util/FileItemHeadersImpl.java
index ebf1fec3eb..47c436fba1 100644
--- a/java/org/apache/tomcat/util/http/fileupload/util/FileItemHeadersImpl.java
+++ b/java/org/apache/tomcat/util/http/fileupload/util/FileItemHeadersImpl.java
@@ -87,7 +87,8 @@ public class FileItemHeadersImpl implements FileItemHeaders,
Serializable {
*/
public synchronized void addHeader(final String name, final String value) {
final String nameLower = name.toLowerCase(Locale.ENGLISH);
- List<String> headerValueList =
headerNameToValueListMap.computeIfAbsent(nameLower, k -> new ArrayList<>());
+ final List<String> headerValueList = headerNameToValueListMap.
+ computeIfAbsent(nameLower, k -> new ArrayList<>());
headerValueList.add(value);
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index ff39b630e3..bb212424cb 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -162,6 +162,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: [email protected]
For additional commands, e-mail: [email protected]