Re: Tomcat's fork of Commons File Upload

2023-09-16 Thread Mark Thomas

On 15/09/2023 19:34, Mark Thomas wrote:



I tend to agree with sticking with 1.x. However, it appears I was 
underestimating somewhat when I said Tomcat had a "few" commits that 1.x 
didn't have.


I still think this is the way to go but there are ~3 years worth of 
commits to work through. Also, Tomcat has picked up some of the 2.x 
refactoring that will need to be reverted. It looks like this is going 
to take a while.


Yuck. That wasn't fun. The current position is:

- all branches are (roughly) aligned with the current FileUpload 1.x
- some 2.x refactoring (mainly the extraction of the Exceptions and the
  FileItemIteratorImpl) remains in the Tomcat forks
- Tomcat 10.1.x onwards has removed some additional unused code

I think there is some refactoring that could be done in FileUpload 1.x 
without breaking binary compatibility that would closer align Tomcat and 
FileUpload 1.x.


Given the previous changes in FileUpload we could probably back-port the 
additional code removal commits from 10.1.x to 9.0.x/8.5.x.


We could probably also revert any remaining refactoring changes Tomcat 
has that 1.x doesn't after the above changes.


I have a few checks I want to run, particularly around bug 65710, to 
make sure I haven't broken anything. Apart from any additional fixes 
those checks highlight, I don't plan on any further alignment work 
before the next release round.


I'm not convinced further alignment work (along the lines of the three 
points above) is beneficial right now. I may revisit that decision later 
if maintaining the current level of alignment proves difficult.


Mark

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



[tomcat] 04/04: Update changelog

2023-09-16 Thread markt
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 34bbe1b00d6d9641753fc7978c2b32ff3fed1960
Author: Mark Thomas 
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 6e13af1c67..361fc0e904 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -135,6 +135,16 @@
   
 
   
+  
+
+  
+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)
+  
+
+  
 
 
   


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



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

2023-09-16 Thread markt
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 a8e5f828605001dd53110c172f474d7bfe74
Author: Mark Thomas 
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 +-
 .../http/fileupload/servlet/ServletRequestContext.java|  4 +---
 .../apache/tomcat/util/http/fileupload/util/Streams.java  |  6 +++---
 .../util/http/fileupload/util/mime/RFC2231Utility.java| 15 +++
 6 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java 
b/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
index d527313723..b9f5cfe174 100644
--- a/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
+++ b/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
@@ -196,11 +196,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;
 }
 
@@ -507,8 +507,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 f748680f86..b02edb35e1 100644
--- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
+++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
@@ -396,8 +396,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;
@@ -586,8 +585,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 aad8795615..8ec7f9df55 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/ServletRequestContext.java
 
b/java/org/apache/tomcat/util/http/fileupload/servlet/ServletRequestContext.java
index abf400836d..3eb51f9a9a 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 jakarta.servlet.http.HttpServletRequest;
 import org.apache.tomcat.util.http.fileupload.FileUploadBase;
 import org.apache.tomcat.util.http.fileupload.UploadContext;
 
-
 /**
  * Provides access to the request information needed for a request made to
  * an HTTP servlet.
@@ -110,8 +109,7 @@ public class ServletRequestContext implements UploadContext 
{
 @Override
 public String toString() {
 return 

[tomcat] 03/04: Better Javadoc / comments

2023-09-16 Thread markt
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 02250f736ca1150f85de87c654f32a837f2d0cf5
Author: Mark Thomas 
AuthorDate: Fri Sep 15 22:54:26 2023 +0100

Better Javadoc / comments
---
 java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java| 4 ++--
 .../apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java  | 4 ++--
 2 files changed, 4 insertions(+), 4 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 225ce89d30..c0a2bd8617 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.
  *
- * Temporary files, which are created for file items, should be
- * deleted later on.
+ * Temporary files, which are created for file items, will be deleted when
+ * the associated request is recycled.
  *
  * @since 1.1
  */
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 8ec7f9df55..ce1eec2f24 100644
--- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java
+++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java
@@ -51,8 +51,8 @@ import org.apache.tomcat.util.http.fileupload.FileItemFactory;
  * may be used.
  * 
  *
- * Temporary files, which are created for file items, should be
- * deleted later on.
+ * Temporary files, which are created for file items, will be deleted when
+ * the associated request is recycled.
  *
  * @since 1.1
  */


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



[tomcat] 02/04: Throw original exception

2023-09-16 Thread markt
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 57a1d961255265e42fe9c41c24ad62594ca0e547
Author: Mark Thomas 
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 b02edb35e1..225ce89d30 100644
--- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
+++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
@@ -375,8 +375,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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] branch main updated (7cd861ee47 -> 34bbe1b00d)

2023-09-16 Thread markt
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 7cd861ee47 Remove unnecessary @SuppressWarnings
 new a8e5f82860 Improve alignment with Commons FileUpload 1.x
 new 57a1d96125 Throw original exception
 new 02250f736c Better Javadoc / comments
 new 34bbe1b00d Update changelog

The 4 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:
 .../tomcat/util/http/fileupload/FileUploadBase.java   |  7 +++
 .../tomcat/util/http/fileupload/disk/DiskFileItem.java| 12 
 .../util/http/fileupload/disk/DiskFileItemFactory.java|  6 +++---
 .../http/fileupload/servlet/ServletRequestContext.java|  4 +---
 .../apache/tomcat/util/http/fileupload/util/Streams.java  |  6 +++---
 .../util/http/fileupload/util/mime/RFC2231Utility.java| 15 +++
 webapps/docs/changelog.xml| 10 ++
 7 files changed, 31 insertions(+), 29 deletions(-)


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



[tomcat] 03/04: Better Javadoc / comments

2023-09-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit f45cb9930d22e7a8da6691b5477ae88f4ab16975
Author: Mark Thomas 
AuthorDate: Fri Sep 15 22:54:26 2023 +0100

Better Javadoc / comments
---
 java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java| 4 ++--
 .../apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java  | 4 ++--
 2 files changed, 4 insertions(+), 4 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 225ce89d30..c0a2bd8617 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.
  *
- * Temporary files, which are created for file items, should be
- * deleted later on.
+ * Temporary files, which are created for file items, will be deleted when
+ * the associated request is recycled.
  *
  * @since 1.1
  */
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 8ec7f9df55..ce1eec2f24 100644
--- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java
+++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java
@@ -51,8 +51,8 @@ import org.apache.tomcat.util.http.fileupload.FileItemFactory;
  * may be used.
  * 
  *
- * Temporary files, which are created for file items, should be
- * deleted later on.
+ * Temporary files, which are created for file items, will be deleted when
+ * the associated request is recycled.
  *
  * @since 1.1
  */


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



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

2023-09-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit ff9771421a1a3989a9e4d618848aa32483d660ab
Author: Mark Thomas 
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 +-
 .../http/fileupload/servlet/ServletRequestContext.java|  4 +---
 .../apache/tomcat/util/http/fileupload/util/Streams.java  |  6 +++---
 .../util/http/fileupload/util/mime/RFC2231Utility.java| 15 +++
 6 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java 
b/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
index d527313723..b9f5cfe174 100644
--- a/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
+++ b/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
@@ -196,11 +196,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;
 }
 
@@ -507,8 +507,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 f748680f86..b02edb35e1 100644
--- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
+++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
@@ -396,8 +396,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;
@@ -586,8 +585,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 aad8795615..8ec7f9df55 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/ServletRequestContext.java
 
b/java/org/apache/tomcat/util/http/fileupload/servlet/ServletRequestContext.java
index abf400836d..3eb51f9a9a 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 jakarta.servlet.http.HttpServletRequest;
 import org.apache.tomcat.util.http.fileupload.FileUploadBase;
 import org.apache.tomcat.util.http.fileupload.UploadContext;
 
-
 /**
  * Provides access to the request information needed for a request made to
  * an HTTP servlet.
@@ -110,8 +109,7 @@ public class ServletRequestContext implements UploadContext 
{
 @Override
 public String toString() {
 return 

[tomcat] 04/04: Update changelog

2023-09-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit f8a6653954bce8efbb05f57c2a430103fde221f1
Author: Mark Thomas 
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 977e085e3a..87445c1198 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -135,6 +135,16 @@
   
 
   
+  
+
+  
+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)
+  
+
+  
 
 
   


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



[tomcat] branch 10.1.x updated (16dce0a5e0 -> f8a6653954)

2023-09-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


from 16dce0a5e0 Remove unnecessary @SuppressWarnings
 new ff9771421a Improve alignment with Commons FileUpload 1.x
 new 8dca17050f Throw original exception
 new f45cb9930d Better Javadoc / comments
 new f8a6653954 Update changelog

The 4 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:
 .../tomcat/util/http/fileupload/FileUploadBase.java   |  7 +++
 .../tomcat/util/http/fileupload/disk/DiskFileItem.java| 12 
 .../util/http/fileupload/disk/DiskFileItemFactory.java|  6 +++---
 .../http/fileupload/servlet/ServletRequestContext.java|  4 +---
 .../apache/tomcat/util/http/fileupload/util/Streams.java  |  6 +++---
 .../util/http/fileupload/util/mime/RFC2231Utility.java| 15 +++
 webapps/docs/changelog.xml| 10 ++
 7 files changed, 31 insertions(+), 29 deletions(-)


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



[tomcat] 02/04: Throw original exception

2023-09-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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

commit 8dca17050f28726eaee76b300d34ccda2f1430a2
Author: Mark Thomas 
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 b02edb35e1..225ce89d30 100644
--- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
+++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
@@ -375,8 +375,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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] branch 8.5.x updated: One more false positive when running via Ant

2023-09-16 Thread markt
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 d79e9c0011 One more false positive when running via Ant
d79e9c0011 is described below

commit d79e9c0011d314ccd5669dcb89ea68614ff7bf0e
Author: Mark Thomas 
AuthorDate: Sat Sep 16 10:39:29 2023 +0100

One more false positive when running via Ant
---
 res/spotbugs/filter-false-positives.xml | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/res/spotbugs/filter-false-positives.xml 
b/res/spotbugs/filter-false-positives.xml
index 64ea238d31..1f6307e60a 100644
--- a/res/spotbugs/filter-false-positives.xml
+++ b/res/spotbugs/filter-false-positives.xml
@@ -350,6 +350,13 @@
 
 
   
+  
+
+
+
+
+
+  
   
 
 


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



[tomcat] 01/03: Update false positives for FileUpload

2023-09-16 Thread markt
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

commit bf7bd10432f02e4a2428ef4d33dfc3a2d3081948
Author: Mark Thomas 
AuthorDate: Sat Sep 16 09:56:50 2023 +0100

Update false positives for FileUpload
---
 res/spotbugs/filter-false-positives.xml | 23 +--
 1 file changed, 1 insertion(+), 22 deletions(-)

diff --git a/res/spotbugs/filter-false-positives.xml 
b/res/spotbugs/filter-false-positives.xml
index 9794f86322..70baa748a0 100644
--- a/res/spotbugs/filter-false-positives.xml
+++ b/res/spotbugs/filter-false-positives.xml
@@ -1547,33 +1547,12 @@
 
 
   
-  
-
-
-
-
-  
   
 
 
-
-  
-  
-
+
 
   
-  
-
-
-
-
-  
-  
-
-
-
-
-  
   
 
 


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



[tomcat] branch 8.5.x updated (a5e30c15f4 -> 0f6899cb98)

2023-09-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


from a5e30c15f4 Update changelog
 new bf7bd10432 Update false positives for FileUpload
 new 7a4d356d70 Fix SpotBugs warning
 new 0f6899cb98 Suppress a false positive

The 3 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:
 res/spotbugs/filter-false-positives.xml| 29 ++
 .../tomcat/websocket/server/TesterWsClient.java|  3 +++
 2 files changed, 10 insertions(+), 22 deletions(-)


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



[tomcat] 03/03: Suppress a false positive

2023-09-16 Thread markt
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

commit 0f6899cb98f2fc70ef753701886bbdfce1a109f4
Author: Mark Thomas 
AuthorDate: Sat Sep 16 10:00:03 2023 +0100

Suppress a false positive
---
 res/spotbugs/filter-false-positives.xml | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/res/spotbugs/filter-false-positives.xml 
b/res/spotbugs/filter-false-positives.xml
index 70baa748a0..64ea238d31 100644
--- a/res/spotbugs/filter-false-positives.xml
+++ b/res/spotbugs/filter-false-positives.xml
@@ -1041,6 +1041,12 @@
 
 
   
+  
+
+
+
+
+  
   
 
 


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



[tomcat] 02/03: Fix SpotBugs warning

2023-09-16 Thread markt
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

commit 7a4d356d70c5871c7efd33adcd29fcf99642a0cf
Author: Mark Thomas 
AuthorDate: Sat Sep 16 09:57:16 2023 +0100

Fix SpotBugs warning
---
 test/org/apache/tomcat/websocket/server/TesterWsClient.java | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/test/org/apache/tomcat/websocket/server/TesterWsClient.java 
b/test/org/apache/tomcat/websocket/server/TesterWsClient.java
index c90aa23ed6..5c47dd21c7 100644
--- a/test/org/apache/tomcat/websocket/server/TesterWsClient.java
+++ b/test/org/apache/tomcat/websocket/server/TesterWsClient.java
@@ -76,6 +76,9 @@ public class TesterWsClient {
 BufferedReader in = new BufferedReader(new 
InputStreamReader(socket.getInputStream()));
 String line = in.readLine();
 // line expected to be "HTTP/1.1 nnn "
+if (line == null) {
+throw new IOException("No response line");
+}
 int result = Integer.parseInt(line.substring(9, 12));
 while (line != null && !line.isEmpty()) {
 line = in.readLine();


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



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

2023-09-16 Thread markt
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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 05/05: Update changelog

2023-09-16 Thread markt
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 
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 @@
   
 
   
+  
+
+  
+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)
+  
+
+  
 
 
   


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



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

2023-09-16 Thread markt
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 
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;
 
-
 /**
  * High level API for processing file uploads.
  *
diff --git 
a/java/org/apache/tomcat/util/http/fileupload/servlet/ServletRequestContext.java
 

[tomcat] 04/05: Better Javadoc / comments

2023-09-16 Thread markt
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 
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.
  *
- * Temporary files, which are created for file items, should be
- * deleted later on.
+ * Temporary files, which are created for file items, will be deleted when
+ * the associated request is recycled.
  *
  * @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.
  * 
  *
- * Temporary files, which are created for file items, should be
- * deleted later on.
+ * Temporary files, which are created for file items, will be deleted when
+ * the associated request is recycled.
  *
  * @since 1.1
  */


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



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

2023-09-16 Thread markt
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 
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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 02/05: Throw original exception

2023-09-16 Thread markt
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 
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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] branch 8.5.x updated: Update changelog

2023-09-16 Thread markt
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 a5e30c15f4 Update changelog
a5e30c15f4 is described below

commit a5e30c15f46ea5ea7596d626d81f20e92b1025ee
Author: Mark Thomas 
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 665c4daa63..096d46850f 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -135,6 +135,16 @@
   
 
   
+  
+
+  
+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)
+  
+
+  
 
 
   


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



[tomcat] branch 8.5.x updated: Remove unnecessary @SuppressWarnings

2023-09-16 Thread markt
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 e16787351d Remove unnecessary @SuppressWarnings
e16787351d is described below

commit e16787351d05dc3cb6c57081e2860f23e3d3995a
Author: Mark Thomas 
AuthorDate: Sat Sep 16 09:25:35 2023 +0100

Remove unnecessary @SuppressWarnings
---
 java/org/apache/tomcat/util/IntrospectionUtils.java | 1 -
 1 file changed, 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/IntrospectionUtils.java 
b/java/org/apache/tomcat/util/IntrospectionUtils.java
index 58ebef56d3..ab4d533b10 100644
--- a/java/org/apache/tomcat/util/IntrospectionUtils.java
+++ b/java/org/apache/tomcat/util/IntrospectionUtils.java
@@ -374,7 +374,6 @@ public final class IntrospectionUtils {
 return methods;
 }
 
-@SuppressWarnings("null") // params cannot be null when comparing lengths
 public static Method findMethod(Class c, String name,
 Class params[]) {
 Method methods[] = findMethods(c);


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



[tomcat] branch 9.0.x updated: Remove unnecessary @SuppressWarnings

2023-09-16 Thread markt
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 0debf210d2 Remove unnecessary @SuppressWarnings
0debf210d2 is described below

commit 0debf210d21054ca04a4b06610212dcce6a38896
Author: Mark Thomas 
AuthorDate: Sat Sep 16 09:25:35 2023 +0100

Remove unnecessary @SuppressWarnings
---
 java/org/apache/tomcat/util/IntrospectionUtils.java | 1 -
 1 file changed, 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/IntrospectionUtils.java 
b/java/org/apache/tomcat/util/IntrospectionUtils.java
index c477dbd880..37ae94533e 100644
--- a/java/org/apache/tomcat/util/IntrospectionUtils.java
+++ b/java/org/apache/tomcat/util/IntrospectionUtils.java
@@ -417,7 +417,6 @@ public final class IntrospectionUtils {
 return methods;
 }
 
-@SuppressWarnings("null") // params cannot be null when comparing lengths
 public static Method findMethod(Class c, String name,
 Class params[]) {
 Method methods[] = findMethods(c);


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



[tomcat] branch 10.1.x updated: Remove unnecessary @SuppressWarnings

2023-09-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 16dce0a5e0 Remove unnecessary @SuppressWarnings
16dce0a5e0 is described below

commit 16dce0a5e0cb95950e299db10ab9243e5c5bc535
Author: Mark Thomas 
AuthorDate: Sat Sep 16 09:25:35 2023 +0100

Remove unnecessary @SuppressWarnings
---
 java/org/apache/tomcat/util/IntrospectionUtils.java | 1 -
 1 file changed, 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/IntrospectionUtils.java 
b/java/org/apache/tomcat/util/IntrospectionUtils.java
index 7ea1964b72..bcaffedbbb 100644
--- a/java/org/apache/tomcat/util/IntrospectionUtils.java
+++ b/java/org/apache/tomcat/util/IntrospectionUtils.java
@@ -422,7 +422,6 @@ public final class IntrospectionUtils {
 return methods;
 }
 
-@SuppressWarnings("null") // params cannot be null when comparing lengths
 public static Method findMethod(Class c, String name,
 Class params[]) {
 Method methods[] = findMethods(c);


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



[tomcat] branch main updated: Remove unnecessary @SuppressWarnings

2023-09-16 Thread markt
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


The following commit(s) were added to refs/heads/main by this push:
 new 7cd861ee47 Remove unnecessary @SuppressWarnings
7cd861ee47 is described below

commit 7cd861ee476320e253832e5a359e5b43dabf87b4
Author: Mark Thomas 
AuthorDate: Sat Sep 16 09:25:35 2023 +0100

Remove unnecessary @SuppressWarnings
---
 java/org/apache/tomcat/util/IntrospectionUtils.java | 1 -
 1 file changed, 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/IntrospectionUtils.java 
b/java/org/apache/tomcat/util/IntrospectionUtils.java
index bacda81eb2..e819bd207c 100644
--- a/java/org/apache/tomcat/util/IntrospectionUtils.java
+++ b/java/org/apache/tomcat/util/IntrospectionUtils.java
@@ -416,7 +416,6 @@ public final class IntrospectionUtils {
 return methods;
 }
 
-@SuppressWarnings("null") // params cannot be null when comparing lengths
 public static Method findMethod(Class c, String name,
 Class params[]) {
 Method methods[] = findMethods(c);


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



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

2023-09-16 Thread markt
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

commit 991dd7d482ddf0b72374d284e3c0276ff806c788
Author: Mark Thomas 
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 d8dbd691f8..51bcc9c3f4 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;
 }
 
@@ -565,8 +565,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 228a061de7..bc886495be 100644
--- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
+++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
@@ -395,8 +395,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;
@@ -585,8 +584,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;
 
-
 /**
  * High level API for processing file uploads.
  *
diff --git 
a/java/org/apache/tomcat/util/http/fileupload/servlet/ServletRequestContext.java
 

[tomcat] 02/04: Throw original exception

2023-09-16 Thread markt
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

commit 9634ac3ad73531c6241ce375f5cbd9add760ce37
Author: Mark Thomas 
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 bc886495be..bf4022164d 100644
--- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
+++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
@@ -374,8 +374,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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



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

2023-09-16 Thread markt
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

commit c99ffc30e95ddc4daede564d08cb5ea2b9a9da65
Author: Mark Thomas 
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 bf4022164d..7fcd7f7653 100644
--- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
+++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
@@ -528,6 +528,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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 04/04: Better Javadoc / comments

2023-09-16 Thread markt
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

commit 470339e34ffea488863c043cc1b216392c8312d6
Author: Mark Thomas 
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 7fcd7f7653..1f6a70af95 100644
--- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
+++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
@@ -52,8 +52,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.
  *
- * Temporary files, which are created for file items, should be
- * deleted later on.
+ * Temporary files, which are created for file items, will be deleted when
+ * the associated request is recycled.
  *
  * @since 1.1
  */
@@ -192,7 +192,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.
  * 
  *
- * Temporary files, which are created for file items, should be
- * deleted later on.
+ * Temporary files, which are created for file items, will be deleted when
+ * the associated request is recycled.
  *
  * @since 1.1
  */


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



[tomcat] branch 8.5.x updated (f9744d4163 -> 470339e34f)

2023-09-16 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


from f9744d4163 Fix NPE causing a failure to match
 new 991dd7d482 Improve alignment with Commons FileUpload 1.x
 new 9634ac3ad7 Throw original exception
 new c99ffc30e9 Restore the finalize() method
 new 470339e34f Better Javadoc / comments

The 4 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 ++-
 7 files changed, 39 insertions(+), 34 deletions(-)


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