Re: Tomcat's fork of Commons File Upload

2023-09-15 Thread Mark Thomas

On 15/09/2023 18:55, Coty Sutherland wrote:
On Fri, Sep 15, 2023 at 8:43 AM Rémy Maucherat  wrote: 

On Fri, Sep 15, 2023 at 2:38 PM Mark Thomas  wrote:





Since we have little choice for Tomcat 8.5.x and 9.0.x, I will be
aligning these branches with FileUpload 1.x first.

I'm not a huge fan of pulling a large chunk of Commons IO or on making
sufficient changes to our fork so we don't have to. I am therefore
currently planning on aligning 10.1.x and 11.0.x with FileUpload 1.x as
well.

I do intend to see if there are changes from FileUpload 2.x that are
worth cherry-picking into Tomcat (and FileUpload 1.x) if minimum Java
versions permit.

All that said, the Jakarta EE Migration tool already includes a package
renamed copy of Commons IO (as well as Lang and Compress) so there might
be something we co do there - maybe a new Commons forks JAR?

Thoughts?


+1 on staying with fileupload 1.x for all branches then, for the time
being. 11 could move to 2.x eventually it seems.



+1


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.


Mark

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



Re: Tomcat's fork of Commons File Upload

2023-09-15 Thread Coty Sutherland
On Fri, Sep 15, 2023 at 8:43 AM Rémy Maucherat  wrote:

> On Fri, Sep 15, 2023 at 2:38 PM Mark Thomas  wrote:
> >
> > All,
> >
> > Since the introduction of multi-part upload support in Servlet 3 (Tomcat
> > 7), Tomcat has used a package renamed fork of Commons FileUpload to
> > provide that support.
> >
> > Recently, FileUpload has undergone some major refactoring for 2.x to
> > modularise it to support different versions of the Servlet
> > specification, primarily Java EE vs Jakarta EE. As part of that, the
> > minimum Java version for 2.x is Java 11.
> >
> > The code Tomcat is currently based on is now the essentially 1.x branch.
> > This was created from the 1.4 release so Tomcat currently has a few
> > changes that were not applied to that branch. The minimum Java version
> > for this branch is Java 6.
> >
> > I have spent the last couple of hours looking at updating Tomcat 11.0.x
> > to the 2.x FileUpload code. It is doable, but we'll need to bring in
> > most of Commons IO as well which is about another 500k.
> >
> > Given the minimum Java version requirements, Tomcat 8.5.x and 9.0.x will
> > need to remain based on FileUpload 1.x.
> >
> > Tomcat 10.1.x and Tomcat 11.0.x could opt to remain based on FileUpload
> > 1.x or switch to 2.x.
> >
> > We need to decide what to do.
> >
> > Since we have little choice for Tomcat 8.5.x and 9.0.x, I will be
> > aligning these branches with FileUpload 1.x first.
> >
> > I'm not a huge fan of pulling a large chunk of Commons IO or on making
> > sufficient changes to our fork so we don't have to. I am therefore
> > currently planning on aligning 10.1.x and 11.0.x with FileUpload 1.x as
> > well.
> >
> > I do intend to see if there are changes from FileUpload 2.x that are
> > worth cherry-picking into Tomcat (and FileUpload 1.x) if minimum Java
> > versions permit.
> >
> > All that said, the Jakarta EE Migration tool already includes a package
> > renamed copy of Commons IO (as well as Lang and Compress) so there might
> > be something we co do there - maybe a new Commons forks JAR?
> >
> > Thoughts?
>
> +1 on staying with fileupload 1.x for all branches then, for the time
> being. 11 could move to 2.x eventually it seems.
>

+1


Re: Tomcat's fork of Commons File Upload

2023-09-15 Thread Christopher Schultz

Mark, Rémy,

On 9/15/23 08:43, Rémy Maucherat wrote:

On Fri, Sep 15, 2023 at 2:38 PM Mark Thomas  wrote:


All,

Since the introduction of multi-part upload support in Servlet 3 (Tomcat
7), Tomcat has used a package renamed fork of Commons FileUpload to
provide that support.

Recently, FileUpload has undergone some major refactoring for 2.x to
modularise it to support different versions of the Servlet
specification, primarily Java EE vs Jakarta EE. As part of that, the
minimum Java version for 2.x is Java 11.

The code Tomcat is currently based on is now the essentially 1.x branch.
This was created from the 1.4 release so Tomcat currently has a few
changes that were not applied to that branch. The minimum Java version
for this branch is Java 6.

I have spent the last couple of hours looking at updating Tomcat 11.0.x
to the 2.x FileUpload code. It is doable, but we'll need to bring in
most of Commons IO as well which is about another 500k.

Given the minimum Java version requirements, Tomcat 8.5.x and 9.0.x will
need to remain based on FileUpload 1.x.

Tomcat 10.1.x and Tomcat 11.0.x could opt to remain based on FileUpload
1.x or switch to 2.x.

We need to decide what to do.

Since we have little choice for Tomcat 8.5.x and 9.0.x, I will be
aligning these branches with FileUpload 1.x first.

I'm not a huge fan of pulling a large chunk of Commons IO or on making
sufficient changes to our fork so we don't have to. I am therefore
currently planning on aligning 10.1.x and 11.0.x with FileUpload 1.x as
well.

I do intend to see if there are changes from FileUpload 2.x that are
worth cherry-picking into Tomcat (and FileUpload 1.x) if minimum Java
versions permit.

All that said, the Jakarta EE Migration tool already includes a package
renamed copy of Commons IO (as well as Lang and Compress) so there might
be something we co do there - maybe a new Commons forks JAR?

Thoughts?


+1 on staying with fileupload 1.x for all branches then, for the time
being. 11 could move to 2.x eventually it seems.


+1

-chris

-
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: Fix NPE causing a failure to match

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

remm 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 f9744d4163 Fix NPE causing a failure to match
f9744d4163 is described below

commit f9744d4163761af318c1dfbd3fd10d1acbc91c91
Author: remm 
AuthorDate: Fri Sep 15 16:33:57 2023 +0200

Fix NPE causing a failure to match

If trying to match a no arg method and there's an attempt to match the
same method name with some arguments.
Found by coverity.
---
 java/org/apache/tomcat/util/IntrospectionUtils.java | 8 ++--
 webapps/docs/changelog.xml  | 4 
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/IntrospectionUtils.java 
b/java/org/apache/tomcat/util/IntrospectionUtils.java
index 33ce7fb920..58ebef56d3 100644
--- a/java/org/apache/tomcat/util/IntrospectionUtils.java
+++ b/java/org/apache/tomcat/util/IntrospectionUtils.java
@@ -381,8 +381,12 @@ public final class IntrospectionUtils {
 for (Method method : methods) {
 if (method.getName().equals(name)) {
 Class methodParams[] = method.getParameterTypes();
-if (params == null && methodParams.length == 0) {
-return method;
+if (params == null) {
+if (methodParams.length == 0) {
+return method;
+} else {
+continue;
+}
 }
 if (params.length != methodParams.length) {
 continue;
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index faeb276266..665c4daa63 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -129,6 +129,10 @@
 error handling process is only triggered once per asynchronous cycle.
 (markt)
   
+  
+Fix logic issue trying to match no argument method in IntropectionUtil.
+(remm)
+  
 
   
 


-
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: Fix NPE causing a failure to match

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

remm 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 58367d2891 Fix NPE causing a failure to match
58367d2891 is described below

commit 58367d289173d8d0ef512cf4d320ec8226fc0ea9
Author: remm 
AuthorDate: Fri Sep 15 16:33:57 2023 +0200

Fix NPE causing a failure to match

If trying to match a no arg method and there's an attempt to match the
same method name with some arguments.
Found by coverity.
---
 java/org/apache/tomcat/util/IntrospectionUtils.java | 8 ++--
 webapps/docs/changelog.xml  | 4 
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/IntrospectionUtils.java 
b/java/org/apache/tomcat/util/IntrospectionUtils.java
index 6647498939..c477dbd880 100644
--- a/java/org/apache/tomcat/util/IntrospectionUtils.java
+++ b/java/org/apache/tomcat/util/IntrospectionUtils.java
@@ -424,8 +424,12 @@ public final class IntrospectionUtils {
 for (Method method : methods) {
 if (method.getName().equals(name)) {
 Class methodParams[] = method.getParameterTypes();
-if (params == null && methodParams.length == 0) {
-return method;
+if (params == null) {
+if (methodParams.length == 0) {
+return method;
+} else {
+continue;
+}
 }
 if (params.length != methodParams.length) {
 continue;
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 888c126076..b2e8edf1c8 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -129,6 +129,10 @@
 error handling process is only triggered once per asynchronous cycle.
 (markt)
   
+  
+Fix logic issue trying to match no argument method in IntropectionUtil.
+(remm)
+  
 
   
 


-
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: Fix NPE causing a failure to match

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

remm 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 d3c6c7a00b Fix NPE causing a failure to match
d3c6c7a00b is described below

commit d3c6c7a00b9a5a171710f58e679b17f3b5ca15cd
Author: remm 
AuthorDate: Fri Sep 15 16:33:57 2023 +0200

Fix NPE causing a failure to match

If trying to match a no arg method and there's an attempt to match the
same method name with some arguments.
Found by coverity.
---
 java/org/apache/tomcat/util/IntrospectionUtils.java | 8 ++--
 webapps/docs/changelog.xml  | 4 
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/IntrospectionUtils.java 
b/java/org/apache/tomcat/util/IntrospectionUtils.java
index f2cbf785f6..7ea1964b72 100644
--- a/java/org/apache/tomcat/util/IntrospectionUtils.java
+++ b/java/org/apache/tomcat/util/IntrospectionUtils.java
@@ -429,8 +429,12 @@ public final class IntrospectionUtils {
 for (Method method : methods) {
 if (method.getName().equals(name)) {
 Class methodParams[] = method.getParameterTypes();
-if (params == null && methodParams.length == 0) {
-return method;
+if (params == null) {
+if (methodParams.length == 0) {
+return method;
+} else {
+continue;
+}
 }
 if (params.length != methodParams.length) {
 continue;
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index bc3257c93f..977e085e3a 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -129,6 +129,10 @@
 error handling process is only triggered once per asynchronous cycle.
 (markt)
   
+  
+Fix logic issue trying to match no argument method in IntropectionUtil.
+(remm)
+  
 
   
 


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



[tomcat] branch main updated: Fix NPE causing a failure to match

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

remm 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 ef04ec2d3f Fix NPE causing a failure to match
ef04ec2d3f is described below

commit ef04ec2d3f63c612bbe771b9e9536f4c7b5a2cb7
Author: remm 
AuthorDate: Fri Sep 15 16:33:57 2023 +0200

Fix NPE causing a failure to match

If trying to match a no arg method and there's an attempt to match the
same method name with some arguments.
Found by coverity.
---
 java/org/apache/tomcat/util/IntrospectionUtils.java | 8 ++--
 webapps/docs/changelog.xml  | 4 
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/IntrospectionUtils.java 
b/java/org/apache/tomcat/util/IntrospectionUtils.java
index 45c261c2ad..bacda81eb2 100644
--- a/java/org/apache/tomcat/util/IntrospectionUtils.java
+++ b/java/org/apache/tomcat/util/IntrospectionUtils.java
@@ -423,8 +423,12 @@ public final class IntrospectionUtils {
 for (Method method : methods) {
 if (method.getName().equals(name)) {
 Class methodParams[] = method.getParameterTypes();
-if (params == null && methodParams.length == 0) {
-return method;
+if (params == null) {
+if (methodParams.length == 0) {
+return method;
+} else {
+continue;
+}
 }
 if (params.length != methodParams.length) {
 continue;
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 312ac6362b..6e13af1c67 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -129,6 +129,10 @@
 error handling process is only triggered once per asynchronous cycle.
 (markt)
   
+  
+Fix logic issue trying to match no argument method in IntropectionUtil.
+(remm)
+  
 
   
 


-
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 useless null checks

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

remm 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 09bdf9cc5d Remove useless null checks
09bdf9cc5d is described below

commit 09bdf9cc5d95c2c40f82f41f8bdbdb40fa562f4c
Author: remm 
AuthorDate: Fri Sep 15 16:27:11 2023 +0200

Remove useless null checks

Found by coverity.
---
 java/org/apache/tomcat/util/digester/CallMethodRule.java|  2 +-
 java/org/apache/tomcat/util/digester/SetPropertiesRule.java | 11 +++
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/tomcat/util/digester/CallMethodRule.java 
b/java/org/apache/tomcat/util/digester/CallMethodRule.java
index 60e7382ee0..7d78c997b5 100644
--- a/java/org/apache/tomcat/util/digester/CallMethodRule.java
+++ b/java/org/apache/tomcat/util/digester/CallMethodRule.java
@@ -332,7 +332,7 @@ public class CallMethodRule extends Rule {
 return;
 }
 
-} else if (paramTypes != null && paramTypes.length != 0) {
+} else if (paramTypes.length != 0) {
 
 // In the case where the parameter for the method
 // is taken from the body text, but there is no
diff --git a/java/org/apache/tomcat/util/digester/SetPropertiesRule.java 
b/java/org/apache/tomcat/util/digester/SetPropertiesRule.java
index f24b38e8a6..1b8b7b1658 100644
--- a/java/org/apache/tomcat/util/digester/SetPropertiesRule.java
+++ b/java/org/apache/tomcat/util/digester/SetPropertiesRule.java
@@ -45,14 +45,9 @@ public class SetPropertiesRule extends Rule {
 // Populate the corresponding properties of the top object
 Object top = digester.peek();
 if (digester.log.isDebugEnabled()) {
-if (top != null) {
-digester.log.debug("[SetPropertiesRule]{" + digester.match +
-   "} Set " + top.getClass().getName() +
-   " properties");
-} else {
-digester.log.debug("[SetPropertiesRule]{" + digester.match +
-   "} Set NULL properties");
-}
+digester.log.debug("[SetPropertiesRule]{" + digester.match +
+"} Set " + top.getClass().getName() +
+" properties");
 }
 
 for (int i = 0; i < attributes.getLength(); i++) {


-
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 useless null checks

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

remm 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 3fe9515d1d Remove useless null checks
3fe9515d1d is described below

commit 3fe9515d1dfe0e51ebcd4df41b19bde945c0e5ae
Author: remm 
AuthorDate: Fri Sep 15 16:27:11 2023 +0200

Remove useless null checks

Found by coverity.
---
 java/org/apache/tomcat/util/digester/CallMethodRule.java|  2 +-
 java/org/apache/tomcat/util/digester/SetPropertiesRule.java | 11 +++
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/tomcat/util/digester/CallMethodRule.java 
b/java/org/apache/tomcat/util/digester/CallMethodRule.java
index 91b7e56ed2..3eae7a53db 100644
--- a/java/org/apache/tomcat/util/digester/CallMethodRule.java
+++ b/java/org/apache/tomcat/util/digester/CallMethodRule.java
@@ -291,7 +291,7 @@ public class CallMethodRule extends Rule {
 return;
 }
 
-} else if (paramTypes != null && paramTypes.length != 0) {
+} else if (paramTypes.length != 0) {
 
 // In the case where the parameter for the method
 // is taken from the body text, but there is no
diff --git a/java/org/apache/tomcat/util/digester/SetPropertiesRule.java 
b/java/org/apache/tomcat/util/digester/SetPropertiesRule.java
index 323c3f8362..64a7ff282a 100644
--- a/java/org/apache/tomcat/util/digester/SetPropertiesRule.java
+++ b/java/org/apache/tomcat/util/digester/SetPropertiesRule.java
@@ -66,14 +66,9 @@ public class SetPropertiesRule extends Rule {
 // Populate the corresponding properties of the top object
 Object top = digester.peek();
 if (digester.log.isDebugEnabled()) {
-if (top != null) {
-digester.log.debug("[SetPropertiesRule]{" + digester.match +
-   "} Set " + top.getClass().getName() +
-   " properties");
-} else {
-digester.log.debug("[SetPropertiesRule]{" + digester.match +
-   "} Set NULL properties");
-}
+digester.log.debug("[SetPropertiesRule]{" + digester.match +
+"} Set " + top.getClass().getName() +
+" properties");
 }
 StringBuilder code = digester.getGeneratedCode();
 String variableName = null;


-
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 useless null checks

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

remm 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 4040bb2782 Remove useless null checks
4040bb2782 is described below

commit 4040bb27821ccc548e11c52cb5575a3ddfff39a5
Author: remm 
AuthorDate: Fri Sep 15 16:27:11 2023 +0200

Remove useless null checks

Found by coverity.
---
 java/org/apache/tomcat/util/digester/CallMethodRule.java|  2 +-
 java/org/apache/tomcat/util/digester/SetPropertiesRule.java | 11 +++
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/tomcat/util/digester/CallMethodRule.java 
b/java/org/apache/tomcat/util/digester/CallMethodRule.java
index 91b7e56ed2..3eae7a53db 100644
--- a/java/org/apache/tomcat/util/digester/CallMethodRule.java
+++ b/java/org/apache/tomcat/util/digester/CallMethodRule.java
@@ -291,7 +291,7 @@ public class CallMethodRule extends Rule {
 return;
 }
 
-} else if (paramTypes != null && paramTypes.length != 0) {
+} else if (paramTypes.length != 0) {
 
 // In the case where the parameter for the method
 // is taken from the body text, but there is no
diff --git a/java/org/apache/tomcat/util/digester/SetPropertiesRule.java 
b/java/org/apache/tomcat/util/digester/SetPropertiesRule.java
index 323c3f8362..64a7ff282a 100644
--- a/java/org/apache/tomcat/util/digester/SetPropertiesRule.java
+++ b/java/org/apache/tomcat/util/digester/SetPropertiesRule.java
@@ -66,14 +66,9 @@ public class SetPropertiesRule extends Rule {
 // Populate the corresponding properties of the top object
 Object top = digester.peek();
 if (digester.log.isDebugEnabled()) {
-if (top != null) {
-digester.log.debug("[SetPropertiesRule]{" + digester.match +
-   "} Set " + top.getClass().getName() +
-   " properties");
-} else {
-digester.log.debug("[SetPropertiesRule]{" + digester.match +
-   "} Set NULL properties");
-}
+digester.log.debug("[SetPropertiesRule]{" + digester.match +
+"} Set " + top.getClass().getName() +
+" properties");
 }
 StringBuilder code = digester.getGeneratedCode();
 String variableName = null;


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



[tomcat] branch main updated: Remove useless null checks

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

remm 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 ed6fcee5a3 Remove useless null checks
ed6fcee5a3 is described below

commit ed6fcee5a34fefe2d6f37f9a5b9b22e2ceb36178
Author: remm 
AuthorDate: Fri Sep 15 16:27:11 2023 +0200

Remove useless null checks

Found by coverity.
---
 java/org/apache/tomcat/util/digester/CallMethodRule.java|  2 +-
 java/org/apache/tomcat/util/digester/SetPropertiesRule.java | 11 +++
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/tomcat/util/digester/CallMethodRule.java 
b/java/org/apache/tomcat/util/digester/CallMethodRule.java
index 91b7e56ed2..3eae7a53db 100644
--- a/java/org/apache/tomcat/util/digester/CallMethodRule.java
+++ b/java/org/apache/tomcat/util/digester/CallMethodRule.java
@@ -291,7 +291,7 @@ public class CallMethodRule extends Rule {
 return;
 }
 
-} else if (paramTypes != null && paramTypes.length != 0) {
+} else if (paramTypes.length != 0) {
 
 // In the case where the parameter for the method
 // is taken from the body text, but there is no
diff --git a/java/org/apache/tomcat/util/digester/SetPropertiesRule.java 
b/java/org/apache/tomcat/util/digester/SetPropertiesRule.java
index 323c3f8362..64a7ff282a 100644
--- a/java/org/apache/tomcat/util/digester/SetPropertiesRule.java
+++ b/java/org/apache/tomcat/util/digester/SetPropertiesRule.java
@@ -66,14 +66,9 @@ public class SetPropertiesRule extends Rule {
 // Populate the corresponding properties of the top object
 Object top = digester.peek();
 if (digester.log.isDebugEnabled()) {
-if (top != null) {
-digester.log.debug("[SetPropertiesRule]{" + digester.match +
-   "} Set " + top.getClass().getName() +
-   " properties");
-} else {
-digester.log.debug("[SetPropertiesRule]{" + digester.match +
-   "} Set NULL properties");
-}
+digester.log.debug("[SetPropertiesRule]{" + digester.match +
+"} Set " + top.getClass().getName() +
+" properties");
 }
 StringBuilder code = digester.getGeneratedCode();
 String variableName = null;


-
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: Avoid unlikely NPE

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

remm 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 815fbacbee Avoid unlikely NPE
815fbacbee is described below

commit 815fbacbeec54c83c78ba3abc39e6995b5a5af42
Author: remm 
AuthorDate: Fri Sep 15 15:40:15 2023 +0200

Avoid unlikely NPE

Found by coverity.
---
 java/org/apache/naming/factory/DataSourceLinkFactory.java | 4 ++--
 java/org/apache/naming/factory/SendMailFactory.java   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/naming/factory/DataSourceLinkFactory.java 
b/java/org/apache/naming/factory/DataSourceLinkFactory.java
index cd19e29627..ca360a9a24 100644
--- a/java/org/apache/naming/factory/DataSourceLinkFactory.java
+++ b/java/org/apache/naming/factory/DataSourceLinkFactory.java
@@ -58,8 +58,8 @@ public class DataSourceLinkFactory extends 
ResourceLinkFactory {
 Reference ref = (Reference) obj;
 RefAddr userAttr = ref.get("username");
 RefAddr passAttr = ref.get("password");
-if (userAttr.getContent()!=null && passAttr.getContent()!=null) {
-result = 
wrapDataSource(result,userAttr.getContent().toString(), 
passAttr.getContent().toString());
+if (userAttr != null && passAttr != null && userAttr.getContent() 
!= null && passAttr.getContent() != null) {
+result = wrapDataSource(result, 
userAttr.getContent().toString(), passAttr.getContent().toString());
 }
 }
 return result;
diff --git a/java/org/apache/naming/factory/SendMailFactory.java 
b/java/org/apache/naming/factory/SendMailFactory.java
index 886839ba2b..d91a484081 100644
--- a/java/org/apache/naming/factory/SendMailFactory.java
+++ b/java/org/apache/naming/factory/SendMailFactory.java
@@ -112,7 +112,7 @@ public class SendMailFactory implements ObjectFactory
 RefAddr fromAddr = ref.get("mail.from");
 String from = null;
 if (fromAddr != null) {
-from = (String)ref.get("mail.from").getContent();
+from = (String) fromAddr.getContent();
 }
 if (from != null) {
 message.setFrom(new InternetAddress(from));


-
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: Fix possible NPE

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

remm 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 2b8999e6cb Fix possible NPE
2b8999e6cb is described below

commit 2b8999e6cbce68959f4dd06c4145b1dbd50ecada
Author: remm 
AuthorDate: Fri Sep 15 15:40:15 2023 +0200

Fix possible NPE

And a false positive cleanup.
Found by coverity.
---
 java/org/apache/naming/factory/DataSourceLinkFactory.java | 4 ++--
 java/org/apache/naming/factory/SendMailFactory.java   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/naming/factory/DataSourceLinkFactory.java 
b/java/org/apache/naming/factory/DataSourceLinkFactory.java
index cd19e29627..ca360a9a24 100644
--- a/java/org/apache/naming/factory/DataSourceLinkFactory.java
+++ b/java/org/apache/naming/factory/DataSourceLinkFactory.java
@@ -58,8 +58,8 @@ public class DataSourceLinkFactory extends 
ResourceLinkFactory {
 Reference ref = (Reference) obj;
 RefAddr userAttr = ref.get("username");
 RefAddr passAttr = ref.get("password");
-if (userAttr.getContent()!=null && passAttr.getContent()!=null) {
-result = 
wrapDataSource(result,userAttr.getContent().toString(), 
passAttr.getContent().toString());
+if (userAttr != null && passAttr != null && userAttr.getContent() 
!= null && passAttr.getContent() != null) {
+result = wrapDataSource(result, 
userAttr.getContent().toString(), passAttr.getContent().toString());
 }
 }
 return result;
diff --git a/java/org/apache/naming/factory/SendMailFactory.java 
b/java/org/apache/naming/factory/SendMailFactory.java
index 4ec00d8a71..4edd031513 100644
--- a/java/org/apache/naming/factory/SendMailFactory.java
+++ b/java/org/apache/naming/factory/SendMailFactory.java
@@ -109,7 +109,7 @@ public class SendMailFactory implements ObjectFactory
 RefAddr fromAddr = ref.get("mail.from");
 String from = null;
 if (fromAddr != null) {
-from = 
(String)ref.get("mail.from").getContent();
+from = (String) fromAddr.getContent();
 }
 if (from != null) {
 message.setFrom(new InternetAddress(from));


-
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: Fix possible NPE

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

remm 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 7631b317cb Fix possible NPE
7631b317cb is described below

commit 7631b317cb54a27efbed01ac9eb19ff57b8b1f8a
Author: remm 
AuthorDate: Fri Sep 15 15:40:15 2023 +0200

Fix possible NPE

And a false positive cleanup.
Found by coverity.
---
 java/org/apache/naming/factory/DataSourceLinkFactory.java | 4 ++--
 java/org/apache/naming/factory/SendMailFactory.java   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/naming/factory/DataSourceLinkFactory.java 
b/java/org/apache/naming/factory/DataSourceLinkFactory.java
index cd19e29627..ca360a9a24 100644
--- a/java/org/apache/naming/factory/DataSourceLinkFactory.java
+++ b/java/org/apache/naming/factory/DataSourceLinkFactory.java
@@ -58,8 +58,8 @@ public class DataSourceLinkFactory extends 
ResourceLinkFactory {
 Reference ref = (Reference) obj;
 RefAddr userAttr = ref.get("username");
 RefAddr passAttr = ref.get("password");
-if (userAttr.getContent()!=null && passAttr.getContent()!=null) {
-result = 
wrapDataSource(result,userAttr.getContent().toString(), 
passAttr.getContent().toString());
+if (userAttr != null && passAttr != null && userAttr.getContent() 
!= null && passAttr.getContent() != null) {
+result = wrapDataSource(result, 
userAttr.getContent().toString(), passAttr.getContent().toString());
 }
 }
 return result;
diff --git a/java/org/apache/naming/factory/SendMailFactory.java 
b/java/org/apache/naming/factory/SendMailFactory.java
index 20aee7d8c6..4276d3c1b8 100644
--- a/java/org/apache/naming/factory/SendMailFactory.java
+++ b/java/org/apache/naming/factory/SendMailFactory.java
@@ -110,7 +110,7 @@ public class SendMailFactory implements ObjectFactory
 RefAddr fromAddr = ref.get("mail.from");
 String from = null;
 if (fromAddr != null) {
-from = 
(String)ref.get("mail.from").getContent();
+from = (String) fromAddr.getContent();
 }
 if (from != null) {
 message.setFrom(new InternetAddress(from));


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



[tomcat] branch main updated: Fix possible NPE

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

remm 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 a432937164 Fix possible NPE
a432937164 is described below

commit a4329371648b339668c463c0b51a577fa41c48ab
Author: remm 
AuthorDate: Fri Sep 15 15:40:15 2023 +0200

Fix possible NPE

And a false positive cleanup.
Found by coverity.
---
 java/org/apache/naming/factory/DataSourceLinkFactory.java | 4 ++--
 java/org/apache/naming/factory/SendMailFactory.java   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/naming/factory/DataSourceLinkFactory.java 
b/java/org/apache/naming/factory/DataSourceLinkFactory.java
index 51a086eb36..451961f9a8 100644
--- a/java/org/apache/naming/factory/DataSourceLinkFactory.java
+++ b/java/org/apache/naming/factory/DataSourceLinkFactory.java
@@ -58,8 +58,8 @@ public class DataSourceLinkFactory extends 
ResourceLinkFactory {
 Reference ref = (Reference) obj;
 RefAddr userAttr = ref.get("username");
 RefAddr passAttr = ref.get("password");
-if (userAttr.getContent()!=null && passAttr.getContent()!=null) {
-result = 
wrapDataSource(result,userAttr.getContent().toString(), 
passAttr.getContent().toString());
+if (userAttr != null && passAttr != null && userAttr.getContent() 
!= null && passAttr.getContent() != null) {
+result = wrapDataSource(result, 
userAttr.getContent().toString(), passAttr.getContent().toString());
 }
 }
 return result;
diff --git a/java/org/apache/naming/factory/SendMailFactory.java 
b/java/org/apache/naming/factory/SendMailFactory.java
index 6448b4dfd6..9590b1a5c2 100644
--- a/java/org/apache/naming/factory/SendMailFactory.java
+++ b/java/org/apache/naming/factory/SendMailFactory.java
@@ -105,7 +105,7 @@ public class SendMailFactory implements ObjectFactory
 RefAddr fromAddr = ref.get("mail.from");
 String from = null;
 if (fromAddr != null) {
-from = (String)ref.get("mail.from").getContent();
+from = (String) fromAddr.getContent();
 }
 if (from != null) {
 message.setFrom(new InternetAddress(from));


-
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: Avoid unlikely NPE

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

remm 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 16512fd0a2 Avoid unlikely NPE
16512fd0a2 is described below

commit 16512fd0a250aa202b00da11d2e7cae97d6669bf
Author: remm 
AuthorDate: Fri Sep 15 15:31:25 2023 +0200

Avoid unlikely NPE

Found by coverity.
---
 java/org/apache/naming/NamingContext.java | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/naming/NamingContext.java 
b/java/org/apache/naming/NamingContext.java
index cefa30f37b..5503aa3658 100644
--- a/java/org/apache/naming/NamingContext.java
+++ b/java/org/apache/naming/NamingContext.java
@@ -867,14 +867,17 @@ public class NamingContext implements Context {
 // Use the configured object factory to resolve it 
directly if possible
 // Note: This may need manual constructor reflection 
configuration
 Reference reference = (Reference) entry.value;
-Class factoryClass = 
getClass().getClassLoader().loadClass(reference.getFactoryClassName());
-ObjectFactory factory = (ObjectFactory) 
factoryClass.getDeclaredConstructor().newInstance();
-obj = factory.getObjectInstance(entry.value, name, 
this, env);
+String factoryClassName = 
reference.getFactoryClassName();
+if (factoryClassName != null) {
+Class factoryClass = 
getClass().getClassLoader().loadClass(factoryClassName);
+ObjectFactory factory = (ObjectFactory) 
factoryClass.getDeclaredConstructor().newInstance();
+obj = factory.getObjectInstance(entry.value, name, 
this, env);
+}
 }
 if (entry.value instanceof ResourceRef) {
 boolean singleton = Boolean.parseBoolean(
 (String) ((ResourceRef) entry.value).get(
-"singleton").getContent());
+
ResourceRef.SINGLETON).getContent());
 if (singleton) {
 entry.type = NamingEntry.ENTRY;
 entry.value = obj;


-
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: Avoid unlikely NPE

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

remm 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 3336f331db Avoid unlikely NPE
3336f331db is described below

commit 3336f331dbe92650d43c0a969502beed87038fc2
Author: remm 
AuthorDate: Fri Sep 15 15:31:25 2023 +0200

Avoid unlikely NPE

Found by coverity.
---
 java/org/apache/naming/NamingContext.java | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/naming/NamingContext.java 
b/java/org/apache/naming/NamingContext.java
index cefa30f37b..5503aa3658 100644
--- a/java/org/apache/naming/NamingContext.java
+++ b/java/org/apache/naming/NamingContext.java
@@ -867,14 +867,17 @@ public class NamingContext implements Context {
 // Use the configured object factory to resolve it 
directly if possible
 // Note: This may need manual constructor reflection 
configuration
 Reference reference = (Reference) entry.value;
-Class factoryClass = 
getClass().getClassLoader().loadClass(reference.getFactoryClassName());
-ObjectFactory factory = (ObjectFactory) 
factoryClass.getDeclaredConstructor().newInstance();
-obj = factory.getObjectInstance(entry.value, name, 
this, env);
+String factoryClassName = 
reference.getFactoryClassName();
+if (factoryClassName != null) {
+Class factoryClass = 
getClass().getClassLoader().loadClass(factoryClassName);
+ObjectFactory factory = (ObjectFactory) 
factoryClass.getDeclaredConstructor().newInstance();
+obj = factory.getObjectInstance(entry.value, name, 
this, env);
+}
 }
 if (entry.value instanceof ResourceRef) {
 boolean singleton = Boolean.parseBoolean(
 (String) ((ResourceRef) entry.value).get(
-"singleton").getContent());
+
ResourceRef.SINGLETON).getContent());
 if (singleton) {
 entry.type = NamingEntry.ENTRY;
 entry.value = obj;


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



[tomcat] branch main updated: Avoid unlikely NPE

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

remm 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 9aeef80e3b Avoid unlikely NPE
9aeef80e3b is described below

commit 9aeef80e3b450a1932426e387617fb065b8f7869
Author: remm 
AuthorDate: Fri Sep 15 15:31:25 2023 +0200

Avoid unlikely NPE

Found by coverity.
---
 java/org/apache/naming/NamingContext.java | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/naming/NamingContext.java 
b/java/org/apache/naming/NamingContext.java
index cefa30f37b..5503aa3658 100644
--- a/java/org/apache/naming/NamingContext.java
+++ b/java/org/apache/naming/NamingContext.java
@@ -867,14 +867,17 @@ public class NamingContext implements Context {
 // Use the configured object factory to resolve it 
directly if possible
 // Note: This may need manual constructor reflection 
configuration
 Reference reference = (Reference) entry.value;
-Class factoryClass = 
getClass().getClassLoader().loadClass(reference.getFactoryClassName());
-ObjectFactory factory = (ObjectFactory) 
factoryClass.getDeclaredConstructor().newInstance();
-obj = factory.getObjectInstance(entry.value, name, 
this, env);
+String factoryClassName = 
reference.getFactoryClassName();
+if (factoryClassName != null) {
+Class factoryClass = 
getClass().getClassLoader().loadClass(factoryClassName);
+ObjectFactory factory = (ObjectFactory) 
factoryClass.getDeclaredConstructor().newInstance();
+obj = factory.getObjectInstance(entry.value, name, 
this, env);
+}
 }
 if (entry.value instanceof ResourceRef) {
 boolean singleton = Boolean.parseBoolean(
 (String) ((ResourceRef) entry.value).get(
-"singleton").getContent());
+
ResourceRef.SINGLETON).getContent());
 if (singleton) {
 entry.type = NamingEntry.ENTRY;
 entry.value = obj;


-
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: Fix inconsistent sync

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

remm 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 f2f512ff54 Fix inconsistent sync
f2f512ff54 is described below

commit f2f512ff5498ef7ee3523c6100e0a0409b56425b
Author: remm 
AuthorDate: Fri Sep 15 14:45:43 2023 +0200

Fix inconsistent sync

Found by coverity.
---
 java/org/apache/juli/ClassLoaderLogManager.java | 26 -
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/java/org/apache/juli/ClassLoaderLogManager.java 
b/java/org/apache/juli/ClassLoaderLogManager.java
index 96cfbaed21..ce581a604e 100644
--- a/java/org/apache/juli/ClassLoaderLogManager.java
+++ b/java/org/apache/juli/ClassLoaderLogManager.java
@@ -333,7 +333,7 @@ public class ClassLoaderLogManager extends LogManager {
 }
 
 @Override
-public void reset() throws SecurityException {
+public synchronized void reset() throws SecurityException {
 Thread thread = Thread.currentThread();
 if 
(thread.getClass().getName().startsWith("java.util.logging.LogManager$")) {
 // Ignore the call from java.util.logging.LogManager.Cleaner,
@@ -369,22 +369,20 @@ public class ClassLoaderLogManager extends LogManager {
 // method can use handlers from the parent class loaders, and closing
 // handlers that the current class loader does not own would be not
 // good.
-synchronized (clLogInfo) {
-for (Logger logger : clLogInfo.loggers.values()) {
-Handler[] handlers = logger.getHandlers();
-for (Handler handler : handlers) {
-logger.removeHandler(handler);
-}
+for (Logger logger : clLogInfo.loggers.values()) {
+Handler[] handlers = logger.getHandlers();
+for (Handler handler : handlers) {
+logger.removeHandler(handler);
 }
-for (Handler handler : clLogInfo.handlers.values()) {
-try {
-handler.close();
-} catch (Exception e) {
-// Ignore
-}
+}
+for (Handler handler : clLogInfo.handlers.values()) {
+try {
+handler.close();
+} catch (Exception e) {
+// Ignore
 }
-clLogInfo.handlers.clear();
 }
+clLogInfo.handlers.clear();
 }
 
 // -- Protected Methods


-
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: Fix inconsistent sync

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

remm 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 8cf38cdb77 Fix inconsistent sync
8cf38cdb77 is described below

commit 8cf38cdb7787c87ada0a87e5286af1121526fe29
Author: remm 
AuthorDate: Fri Sep 15 14:45:43 2023 +0200

Fix inconsistent sync

Found by coverity.
---
 java/org/apache/juli/ClassLoaderLogManager.java | 26 -
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/java/org/apache/juli/ClassLoaderLogManager.java 
b/java/org/apache/juli/ClassLoaderLogManager.java
index 099f288f60..1d9f51c75d 100644
--- a/java/org/apache/juli/ClassLoaderLogManager.java
+++ b/java/org/apache/juli/ClassLoaderLogManager.java
@@ -319,7 +319,7 @@ public class ClassLoaderLogManager extends LogManager {
 }
 
 @Override
-public void reset() throws SecurityException {
+public synchronized void reset() throws SecurityException {
 Thread thread = Thread.currentThread();
 if 
(thread.getClass().getName().startsWith("java.util.logging.LogManager$")) {
 // Ignore the call from java.util.logging.LogManager.Cleaner,
@@ -355,22 +355,20 @@ public class ClassLoaderLogManager extends LogManager {
 // method can use handlers from the parent class loaders, and closing
 // handlers that the current class loader does not own would be not
 // good.
-synchronized (clLogInfo) {
-for (Logger logger : clLogInfo.loggers.values()) {
-Handler[] handlers = logger.getHandlers();
-for (Handler handler : handlers) {
-logger.removeHandler(handler);
-}
+for (Logger logger : clLogInfo.loggers.values()) {
+Handler[] handlers = logger.getHandlers();
+for (Handler handler : handlers) {
+logger.removeHandler(handler);
 }
-for (Handler handler : clLogInfo.handlers.values()) {
-try {
-handler.close();
-} catch (Exception e) {
-// Ignore
-}
+}
+for (Handler handler : clLogInfo.handlers.values()) {
+try {
+handler.close();
+} catch (Exception e) {
+// Ignore
 }
-clLogInfo.handlers.clear();
 }
+clLogInfo.handlers.clear();
 }
 
 // -- Protected Methods


-
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: Fix inconsistent sync

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

remm 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 5a8f137c2c Fix inconsistent sync
5a8f137c2c is described below

commit 5a8f137c2cc8ecb460ae57b9682d6eb8cf721827
Author: remm 
AuthorDate: Fri Sep 15 14:45:43 2023 +0200

Fix inconsistent sync

Found by coverity.
---
 java/org/apache/juli/ClassLoaderLogManager.java | 26 -
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/java/org/apache/juli/ClassLoaderLogManager.java 
b/java/org/apache/juli/ClassLoaderLogManager.java
index 14e8bb30b3..0eb11f7005 100644
--- a/java/org/apache/juli/ClassLoaderLogManager.java
+++ b/java/org/apache/juli/ClassLoaderLogManager.java
@@ -307,7 +307,7 @@ public class ClassLoaderLogManager extends LogManager {
 }
 
 @Override
-public void reset() throws SecurityException {
+public synchronized void reset() throws SecurityException {
 Thread thread = Thread.currentThread();
 if 
(thread.getClass().getName().startsWith("java.util.logging.LogManager$")) {
 // Ignore the call from java.util.logging.LogManager.Cleaner,
@@ -343,22 +343,20 @@ public class ClassLoaderLogManager extends LogManager {
 // method can use handlers from the parent class loaders, and closing
 // handlers that the current class loader does not own would be not
 // good.
-synchronized (clLogInfo) {
-for (Logger logger : clLogInfo.loggers.values()) {
-Handler[] handlers = logger.getHandlers();
-for (Handler handler : handlers) {
-logger.removeHandler(handler);
-}
+for (Logger logger : clLogInfo.loggers.values()) {
+Handler[] handlers = logger.getHandlers();
+for (Handler handler : handlers) {
+logger.removeHandler(handler);
 }
-for (Handler handler : clLogInfo.handlers.values()) {
-try {
-handler.close();
-} catch (Exception e) {
-// Ignore
-}
+}
+for (Handler handler : clLogInfo.handlers.values()) {
+try {
+handler.close();
+} catch (Exception e) {
+// Ignore
 }
-clLogInfo.handlers.clear();
 }
+clLogInfo.handlers.clear();
 }
 
 // -- Protected Methods


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



[tomcat] branch main updated: Fix inconsistent sync

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

remm 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 afcdd39ce2 Fix inconsistent sync
afcdd39ce2 is described below

commit afcdd39ce2b465c29821706d2a1421414888eb59
Author: remm 
AuthorDate: Fri Sep 15 14:45:43 2023 +0200

Fix inconsistent sync

Found by coverity.
---
 java/org/apache/juli/ClassLoaderLogManager.java | 26 -
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/java/org/apache/juli/ClassLoaderLogManager.java 
b/java/org/apache/juli/ClassLoaderLogManager.java
index 701fd01168..8a4655e732 100644
--- a/java/org/apache/juli/ClassLoaderLogManager.java
+++ b/java/org/apache/juli/ClassLoaderLogManager.java
@@ -293,7 +293,7 @@ public class ClassLoaderLogManager extends LogManager {
 }
 
 @Override
-public void reset() throws SecurityException {
+public synchronized void reset() throws SecurityException {
 Thread thread = Thread.currentThread();
 if 
(thread.getClass().getName().startsWith("java.util.logging.LogManager$")) {
 // Ignore the call from java.util.logging.LogManager.Cleaner,
@@ -329,22 +329,20 @@ public class ClassLoaderLogManager extends LogManager {
 // method can use handlers from the parent class loaders, and closing
 // handlers that the current class loader does not own would be not
 // good.
-synchronized (clLogInfo) {
-for (Logger logger : clLogInfo.loggers.values()) {
-Handler[] handlers = logger.getHandlers();
-for (Handler handler : handlers) {
-logger.removeHandler(handler);
-}
+for (Logger logger : clLogInfo.loggers.values()) {
+Handler[] handlers = logger.getHandlers();
+for (Handler handler : handlers) {
+logger.removeHandler(handler);
 }
-for (Handler handler : clLogInfo.handlers.values()) {
-try {
-handler.close();
-} catch (Exception e) {
-// Ignore
-}
+}
+for (Handler handler : clLogInfo.handlers.values()) {
+try {
+handler.close();
+} catch (Exception e) {
+// Ignore
 }
-clLogInfo.handlers.clear();
 }
+clLogInfo.handlers.clear();
 }
 
 // -- Protected Methods


-
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: Fix backport

2023-09-15 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 a700d0d95b Fix backport
a700d0d95b is described below

commit a700d0d95b1513fd8c2b1b88cb411f8baf8c81a5
Author: Mark Thomas 
AuthorDate: Fri Sep 15 13:43:10 2023 +0100

Fix backport
---
 java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java | 1 -
 1 file changed, 1 deletion(-)

diff --git a/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java 
b/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java
index d05397ab16..4cd7f7adfb 100644
--- a/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java
+++ b/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java
@@ -16,7 +16,6 @@
  */
 package org.apache.coyote.http11.filters;
 
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 


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



Re: Tomcat's fork of Commons File Upload

2023-09-15 Thread Rémy Maucherat
On Fri, Sep 15, 2023 at 2:38 PM Mark Thomas  wrote:
>
> All,
>
> Since the introduction of multi-part upload support in Servlet 3 (Tomcat
> 7), Tomcat has used a package renamed fork of Commons FileUpload to
> provide that support.
>
> Recently, FileUpload has undergone some major refactoring for 2.x to
> modularise it to support different versions of the Servlet
> specification, primarily Java EE vs Jakarta EE. As part of that, the
> minimum Java version for 2.x is Java 11.
>
> The code Tomcat is currently based on is now the essentially 1.x branch.
> This was created from the 1.4 release so Tomcat currently has a few
> changes that were not applied to that branch. The minimum Java version
> for this branch is Java 6.
>
> I have spent the last couple of hours looking at updating Tomcat 11.0.x
> to the 2.x FileUpload code. It is doable, but we'll need to bring in
> most of Commons IO as well which is about another 500k.
>
> Given the minimum Java version requirements, Tomcat 8.5.x and 9.0.x will
> need to remain based on FileUpload 1.x.
>
> Tomcat 10.1.x and Tomcat 11.0.x could opt to remain based on FileUpload
> 1.x or switch to 2.x.
>
> We need to decide what to do.
>
> Since we have little choice for Tomcat 8.5.x and 9.0.x, I will be
> aligning these branches with FileUpload 1.x first.
>
> I'm not a huge fan of pulling a large chunk of Commons IO or on making
> sufficient changes to our fork so we don't have to. I am therefore
> currently planning on aligning 10.1.x and 11.0.x with FileUpload 1.x as
> well.
>
> I do intend to see if there are changes from FileUpload 2.x that are
> worth cherry-picking into Tomcat (and FileUpload 1.x) if minimum Java
> versions permit.
>
> All that said, the Jakarta EE Migration tool already includes a package
> renamed copy of Commons IO (as well as Lang and Compress) so there might
> be something we co do there - maybe a new Commons forks JAR?
>
> Thoughts?

+1 on staying with fileupload 1.x for all branches then, for the time
being. 11 could move to 2.x eventually it seems.

Rémy

> Mark
>
> PS I'm going to start with 8.5.x (and then 9.0.x) now as I don't think
> we have much choice with those two.
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>

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



Tomcat's fork of Commons File Upload

2023-09-15 Thread Mark Thomas

All,

Since the introduction of multi-part upload support in Servlet 3 (Tomcat 
7), Tomcat has used a package renamed fork of Commons FileUpload to 
provide that support.


Recently, FileUpload has undergone some major refactoring for 2.x to 
modularise it to support different versions of the Servlet 
specification, primarily Java EE vs Jakarta EE. As part of that, the 
minimum Java version for 2.x is Java 11.


The code Tomcat is currently based on is now the essentially 1.x branch. 
This was created from the 1.4 release so Tomcat currently has a few 
changes that were not applied to that branch. The minimum Java version 
for this branch is Java 6.


I have spent the last couple of hours looking at updating Tomcat 11.0.x 
to the 2.x FileUpload code. It is doable, but we'll need to bring in 
most of Commons IO as well which is about another 500k.


Given the minimum Java version requirements, Tomcat 8.5.x and 9.0.x will 
need to remain based on FileUpload 1.x.


Tomcat 10.1.x and Tomcat 11.0.x could opt to remain based on FileUpload 
1.x or switch to 2.x.


We need to decide what to do.

Since we have little choice for Tomcat 8.5.x and 9.0.x, I will be 
aligning these branches with FileUpload 1.x first.


I'm not a huge fan of pulling a large chunk of Commons IO or on making 
sufficient changes to our fork so we don't have to. I am therefore 
currently planning on aligning 10.1.x and 11.0.x with FileUpload 1.x as 
well.


I do intend to see if there are changes from FileUpload 2.x that are 
worth cherry-picking into Tomcat (and FileUpload 1.x) if minimum Java 
versions permit.


All that said, the Jakarta EE Migration tool already includes a package 
renamed copy of Commons IO (as well as Lang and Compress) so there might 
be something we co do there - maybe a new Commons forks JAR?


Thoughts?

Mark

PS I'm going to start with 8.5.x (and then 9.0.x) now as I don't think 
we have much choice with those two.


-
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: Replace inappropriate usages of FileUpload

2023-09-15 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 36427d45ac Replace inappropriate usages of FileUpload
36427d45ac is described below

commit 36427d45ac933d3041c59418bab8c3bfeef2891b
Author: Mark Thomas 
AuthorDate: Fri Sep 15 10:47:37 2023 +0100

Replace inappropriate usages of FileUpload
---
 test/org/apache/catalina/ha/session/TestDeltaRequest.java | 2 +-
 test/org/apache/catalina/loader/TestVirtualContext.java   | 8 
 test/org/apache/catalina/loader/TestWebappClassLoaderWeaving.java | 7 +++
 test/org/apache/catalina/session/FileStoreTest.java   | 7 +++
 test/org/apache/tomcat/util/net/TestSSLHostConfigIntegration.java | 2 +-
 5 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/test/org/apache/catalina/ha/session/TestDeltaRequest.java 
b/test/org/apache/catalina/ha/session/TestDeltaRequest.java
index ba4e874e6f..bc795af10d 100644
--- a/test/org/apache/catalina/ha/session/TestDeltaRequest.java
+++ b/test/org/apache/catalina/ha/session/TestDeltaRequest.java
@@ -17,6 +17,7 @@
 package org.apache.catalina.ha.session;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
@@ -26,7 +27,6 @@ import org.junit.Test;
 import org.apache.catalina.Manager;
 import org.apache.catalina.session.StandardManager;
 import org.apache.tomcat.unittest.TesterContext;
-import org.apache.tomcat.util.http.fileupload.ByteArrayOutputStream;
 
 public class TestDeltaRequest {
 
diff --git a/test/org/apache/catalina/loader/TestVirtualContext.java 
b/test/org/apache/catalina/loader/TestVirtualContext.java
index 558b20954a..a68ff2febb 100644
--- a/test/org/apache/catalina/loader/TestVirtualContext.java
+++ b/test/org/apache/catalina/loader/TestVirtualContext.java
@@ -30,12 +30,12 @@ import org.junit.Test;
 import org.apache.catalina.WebResourceRoot;
 import org.apache.catalina.core.JreMemoryLeakPreventionListener;
 import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.startup.ExpandWar;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.catalina.util.IOTools;
 import org.apache.catalina.webresources.StandardRoot;
 import org.apache.tomcat.util.buf.ByteChunk;
-import org.apache.tomcat.util.http.fileupload.FileUtils;
-import org.apache.tomcat.util.http.fileupload.IOUtils;
 import org.apache.tomcat.util.scan.StandardJarScanner;
 
 public class TestVirtualContext extends TomcatBaseTest {
@@ -267,7 +267,7 @@ public class TestVirtualContext extends TomcatBaseTest {
 FileOutputStream annotatedServletClassOutputStream = new 
FileOutputStream(new File(
 targetPackageForAnnotatedClass, 
MyAnnotatedServlet.class.getSimpleName()
 + ".class"));) {
-IOUtils.copy(annotatedServletClassInputStream, 
annotatedServletClassOutputStream);
+IOTools.flow(annotatedServletClassInputStream, 
annotatedServletClassOutputStream);
 }
 
 ctx.setResources(new StandardRoot(ctx));
@@ -303,7 +303,7 @@ public class TestVirtualContext extends TomcatBaseTest {
 tomcat.start();
 assertPageContains("/test/annotatedServlet", 
MyAnnotatedServlet.MESSAGE);
 tomcat.stop();
-FileUtils.deleteDirectory(additionWebInfClasses);
+ExpandWar.delete(additionWebInfClasses);
 Assert.assertTrue("Failed to clean up [" + tempFile + "]", 
tempFile.delete());
 }
 
diff --git a/test/org/apache/catalina/loader/TestWebappClassLoaderWeaving.java 
b/test/org/apache/catalina/loader/TestWebappClassLoaderWeaving.java
index 141f690ea5..1912264a50 100644
--- a/test/org/apache/catalina/loader/TestWebappClassLoaderWeaving.java
+++ b/test/org/apache/catalina/loader/TestWebappClassLoaderWeaving.java
@@ -32,9 +32,9 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 
 import org.apache.catalina.Context;
+import org.apache.catalina.startup.ExpandWar;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
-import org.apache.tomcat.util.http.fileupload.FileUtils;
 
 public class TestWebappClassLoaderWeaving extends TomcatBaseTest {
 
@@ -60,11 +60,10 @@ public class TestWebappClassLoaderWeaving extends 
TomcatBaseTest {
 
 @AfterClass
 public static void tearDownClass() throws Exception {
-
-FileUtils.deleteDirectory(new File(WEBAPP_DOC_BASE));
-
+ExpandWar.delete(new File(WEBAPP_DOC_BASE));
 }
 
+
 private Tomcat tomcat;
 private Context context;
 private WebappClassLoaderBase loader;
diff --git a/test/org/apache/catalina/session/FileStoreTest.java 
b/test/org/apache/catalina/session/FileStoreTest.java
index 

[tomcat] branch 9.0.x updated: Replace inappropriate usages of FileUpload

2023-09-15 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 523de2495d Replace inappropriate usages of FileUpload
523de2495d is described below

commit 523de2495d0b2f16eff8164a1713cbde365223be
Author: Mark Thomas 
AuthorDate: Fri Sep 15 10:47:37 2023 +0100

Replace inappropriate usages of FileUpload
---
 test/org/apache/catalina/ha/session/TestDeltaRequest.java | 2 +-
 test/org/apache/catalina/loader/TestVirtualContext.java   | 8 
 test/org/apache/catalina/loader/TestWebappClassLoaderWeaving.java | 7 +++
 test/org/apache/catalina/session/FileStoreTest.java   | 7 +++
 test/org/apache/tomcat/util/net/TestSSLHostConfigIntegration.java | 2 +-
 5 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/test/org/apache/catalina/ha/session/TestDeltaRequest.java 
b/test/org/apache/catalina/ha/session/TestDeltaRequest.java
index ba4e874e6f..bc795af10d 100644
--- a/test/org/apache/catalina/ha/session/TestDeltaRequest.java
+++ b/test/org/apache/catalina/ha/session/TestDeltaRequest.java
@@ -17,6 +17,7 @@
 package org.apache.catalina.ha.session;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
@@ -26,7 +27,6 @@ import org.junit.Test;
 import org.apache.catalina.Manager;
 import org.apache.catalina.session.StandardManager;
 import org.apache.tomcat.unittest.TesterContext;
-import org.apache.tomcat.util.http.fileupload.ByteArrayOutputStream;
 
 public class TestDeltaRequest {
 
diff --git a/test/org/apache/catalina/loader/TestVirtualContext.java 
b/test/org/apache/catalina/loader/TestVirtualContext.java
index fc26aecd7a..720817be6b 100644
--- a/test/org/apache/catalina/loader/TestVirtualContext.java
+++ b/test/org/apache/catalina/loader/TestVirtualContext.java
@@ -29,12 +29,12 @@ import org.junit.Test;
 import org.apache.catalina.WebResourceRoot;
 import org.apache.catalina.core.JreMemoryLeakPreventionListener;
 import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.startup.ExpandWar;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.catalina.util.IOTools;
 import org.apache.catalina.webresources.StandardRoot;
 import org.apache.tomcat.util.buf.ByteChunk;
-import org.apache.tomcat.util.http.fileupload.FileUtils;
-import org.apache.tomcat.util.http.fileupload.IOUtils;
 import org.apache.tomcat.util.scan.StandardJarScanner;
 
 public class TestVirtualContext extends TomcatBaseTest {
@@ -266,7 +266,7 @@ public class TestVirtualContext extends TomcatBaseTest {
 FileOutputStream annotatedServletClassOutputStream = new 
FileOutputStream(new File(
 targetPackageForAnnotatedClass, 
MyAnnotatedServlet.class.getSimpleName()
 + ".class"))) {
-IOUtils.copy(annotatedServletClassInputStream, 
annotatedServletClassOutputStream);
+IOTools.flow(annotatedServletClassInputStream, 
annotatedServletClassOutputStream);
 }
 
 ctx.setResources(new StandardRoot(ctx));
@@ -302,7 +302,7 @@ public class TestVirtualContext extends TomcatBaseTest {
 tomcat.start();
 assertPageContains("/test/annotatedServlet", 
MyAnnotatedServlet.MESSAGE);
 tomcat.stop();
-FileUtils.deleteDirectory(additionWebInfClasses);
+ExpandWar.delete(additionWebInfClasses);
 Assert.assertTrue("Failed to clean up [" + tempFile + "]", 
tempFile.delete());
 }
 
diff --git a/test/org/apache/catalina/loader/TestWebappClassLoaderWeaving.java 
b/test/org/apache/catalina/loader/TestWebappClassLoaderWeaving.java
index 141f690ea5..1912264a50 100644
--- a/test/org/apache/catalina/loader/TestWebappClassLoaderWeaving.java
+++ b/test/org/apache/catalina/loader/TestWebappClassLoaderWeaving.java
@@ -32,9 +32,9 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 
 import org.apache.catalina.Context;
+import org.apache.catalina.startup.ExpandWar;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
-import org.apache.tomcat.util.http.fileupload.FileUtils;
 
 public class TestWebappClassLoaderWeaving extends TomcatBaseTest {
 
@@ -60,11 +60,10 @@ public class TestWebappClassLoaderWeaving extends 
TomcatBaseTest {
 
 @AfterClass
 public static void tearDownClass() throws Exception {
-
-FileUtils.deleteDirectory(new File(WEBAPP_DOC_BASE));
-
+ExpandWar.delete(new File(WEBAPP_DOC_BASE));
 }
 
+
 private Tomcat tomcat;
 private Context context;
 private WebappClassLoaderBase loader;
diff --git a/test/org/apache/catalina/session/FileStoreTest.java 
b/test/org/apache/catalina/session/FileStoreTest.java
index 

[tomcat] branch 10.1.x updated: Replace inappropriate usages of FileUpload

2023-09-15 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 a2fd61dc9a Replace inappropriate usages of FileUpload
a2fd61dc9a is described below

commit a2fd61dc9a42aff923a11d6b078c527fb405367a
Author: Mark Thomas 
AuthorDate: Fri Sep 15 10:47:37 2023 +0100

Replace inappropriate usages of FileUpload
---
 test/org/apache/catalina/ha/session/TestDeltaRequest.java | 2 +-
 test/org/apache/catalina/loader/TestVirtualContext.java   | 8 
 test/org/apache/catalina/loader/TestWebappClassLoaderWeaving.java | 7 +++
 test/org/apache/catalina/session/FileStoreTest.java   | 7 +++
 test/org/apache/tomcat/util/net/TestSSLHostConfigIntegration.java | 2 +-
 5 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/test/org/apache/catalina/ha/session/TestDeltaRequest.java 
b/test/org/apache/catalina/ha/session/TestDeltaRequest.java
index ba4e874e6f..bc795af10d 100644
--- a/test/org/apache/catalina/ha/session/TestDeltaRequest.java
+++ b/test/org/apache/catalina/ha/session/TestDeltaRequest.java
@@ -17,6 +17,7 @@
 package org.apache.catalina.ha.session;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
@@ -26,7 +27,6 @@ import org.junit.Test;
 import org.apache.catalina.Manager;
 import org.apache.catalina.session.StandardManager;
 import org.apache.tomcat.unittest.TesterContext;
-import org.apache.tomcat.util.http.fileupload.ByteArrayOutputStream;
 
 public class TestDeltaRequest {
 
diff --git a/test/org/apache/catalina/loader/TestVirtualContext.java 
b/test/org/apache/catalina/loader/TestVirtualContext.java
index 4302af7217..a377d7458a 100644
--- a/test/org/apache/catalina/loader/TestVirtualContext.java
+++ b/test/org/apache/catalina/loader/TestVirtualContext.java
@@ -29,12 +29,12 @@ import org.junit.Test;
 import org.apache.catalina.WebResourceRoot;
 import org.apache.catalina.core.JreMemoryLeakPreventionListener;
 import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.startup.ExpandWar;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.catalina.util.IOTools;
 import org.apache.catalina.webresources.StandardRoot;
 import org.apache.tomcat.util.buf.ByteChunk;
-import org.apache.tomcat.util.http.fileupload.FileUtils;
-import org.apache.tomcat.util.http.fileupload.IOUtils;
 import org.apache.tomcat.util.scan.StandardJarScanner;
 
 public class TestVirtualContext extends TomcatBaseTest {
@@ -267,7 +267,7 @@ public class TestVirtualContext extends TomcatBaseTest {
 FileOutputStream annotatedServletClassOutputStream = new 
FileOutputStream(new File(
 targetPackageForAnnotatedClass, 
MyAnnotatedServlet.class.getSimpleName()
 + ".class"))) {
-IOUtils.copy(annotatedServletClassInputStream, 
annotatedServletClassOutputStream);
+IOTools.flow(annotatedServletClassInputStream, 
annotatedServletClassOutputStream);
 }
 
 ctx.setResources(new StandardRoot(ctx));
@@ -303,7 +303,7 @@ public class TestVirtualContext extends TomcatBaseTest {
 tomcat.start();
 assertPageContains("/test/annotatedServlet", 
MyAnnotatedServlet.MESSAGE);
 tomcat.stop();
-FileUtils.deleteDirectory(additionWebInfClasses);
+ExpandWar.delete(additionWebInfClasses);
 Assert.assertTrue("Failed to clean up [" + tempFile + "]", 
tempFile.delete());
 }
 
diff --git a/test/org/apache/catalina/loader/TestWebappClassLoaderWeaving.java 
b/test/org/apache/catalina/loader/TestWebappClassLoaderWeaving.java
index 141f690ea5..1912264a50 100644
--- a/test/org/apache/catalina/loader/TestWebappClassLoaderWeaving.java
+++ b/test/org/apache/catalina/loader/TestWebappClassLoaderWeaving.java
@@ -32,9 +32,9 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 
 import org.apache.catalina.Context;
+import org.apache.catalina.startup.ExpandWar;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
-import org.apache.tomcat.util.http.fileupload.FileUtils;
 
 public class TestWebappClassLoaderWeaving extends TomcatBaseTest {
 
@@ -60,11 +60,10 @@ public class TestWebappClassLoaderWeaving extends 
TomcatBaseTest {
 
 @AfterClass
 public static void tearDownClass() throws Exception {
-
-FileUtils.deleteDirectory(new File(WEBAPP_DOC_BASE));
-
+ExpandWar.delete(new File(WEBAPP_DOC_BASE));
 }
 
+
 private Tomcat tomcat;
 private Context context;
 private WebappClassLoaderBase loader;
diff --git a/test/org/apache/catalina/session/FileStoreTest.java 
b/test/org/apache/catalina/session/FileStoreTest.java
index 

[tomcat] branch main updated: Replace inappropriate usages of FileUpload

2023-09-15 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 4d7f4a03c3 Replace inappropriate usages of FileUpload
4d7f4a03c3 is described below

commit 4d7f4a03c394e174c8bbef3654167161cc36c937
Author: Mark Thomas 
AuthorDate: Fri Sep 15 10:47:37 2023 +0100

Replace inappropriate usages of FileUpload
---
 test/org/apache/catalina/ha/session/TestDeltaRequest.java | 2 +-
 test/org/apache/catalina/loader/TestVirtualContext.java   | 8 
 test/org/apache/catalina/loader/TestWebappClassLoaderWeaving.java | 7 +++
 test/org/apache/catalina/session/FileStoreTest.java   | 7 +++
 test/org/apache/tomcat/util/net/TestSSLHostConfigIntegration.java | 2 +-
 5 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/test/org/apache/catalina/ha/session/TestDeltaRequest.java 
b/test/org/apache/catalina/ha/session/TestDeltaRequest.java
index ba4e874e6f..bc795af10d 100644
--- a/test/org/apache/catalina/ha/session/TestDeltaRequest.java
+++ b/test/org/apache/catalina/ha/session/TestDeltaRequest.java
@@ -17,6 +17,7 @@
 package org.apache.catalina.ha.session;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
@@ -26,7 +27,6 @@ import org.junit.Test;
 import org.apache.catalina.Manager;
 import org.apache.catalina.session.StandardManager;
 import org.apache.tomcat.unittest.TesterContext;
-import org.apache.tomcat.util.http.fileupload.ByteArrayOutputStream;
 
 public class TestDeltaRequest {
 
diff --git a/test/org/apache/catalina/loader/TestVirtualContext.java 
b/test/org/apache/catalina/loader/TestVirtualContext.java
index 4302af7217..a377d7458a 100644
--- a/test/org/apache/catalina/loader/TestVirtualContext.java
+++ b/test/org/apache/catalina/loader/TestVirtualContext.java
@@ -29,12 +29,12 @@ import org.junit.Test;
 import org.apache.catalina.WebResourceRoot;
 import org.apache.catalina.core.JreMemoryLeakPreventionListener;
 import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.startup.ExpandWar;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.catalina.util.IOTools;
 import org.apache.catalina.webresources.StandardRoot;
 import org.apache.tomcat.util.buf.ByteChunk;
-import org.apache.tomcat.util.http.fileupload.FileUtils;
-import org.apache.tomcat.util.http.fileupload.IOUtils;
 import org.apache.tomcat.util.scan.StandardJarScanner;
 
 public class TestVirtualContext extends TomcatBaseTest {
@@ -267,7 +267,7 @@ public class TestVirtualContext extends TomcatBaseTest {
 FileOutputStream annotatedServletClassOutputStream = new 
FileOutputStream(new File(
 targetPackageForAnnotatedClass, 
MyAnnotatedServlet.class.getSimpleName()
 + ".class"))) {
-IOUtils.copy(annotatedServletClassInputStream, 
annotatedServletClassOutputStream);
+IOTools.flow(annotatedServletClassInputStream, 
annotatedServletClassOutputStream);
 }
 
 ctx.setResources(new StandardRoot(ctx));
@@ -303,7 +303,7 @@ public class TestVirtualContext extends TomcatBaseTest {
 tomcat.start();
 assertPageContains("/test/annotatedServlet", 
MyAnnotatedServlet.MESSAGE);
 tomcat.stop();
-FileUtils.deleteDirectory(additionWebInfClasses);
+ExpandWar.delete(additionWebInfClasses);
 Assert.assertTrue("Failed to clean up [" + tempFile + "]", 
tempFile.delete());
 }
 
diff --git a/test/org/apache/catalina/loader/TestWebappClassLoaderWeaving.java 
b/test/org/apache/catalina/loader/TestWebappClassLoaderWeaving.java
index 141f690ea5..1912264a50 100644
--- a/test/org/apache/catalina/loader/TestWebappClassLoaderWeaving.java
+++ b/test/org/apache/catalina/loader/TestWebappClassLoaderWeaving.java
@@ -32,9 +32,9 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 
 import org.apache.catalina.Context;
+import org.apache.catalina.startup.ExpandWar;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
-import org.apache.tomcat.util.http.fileupload.FileUtils;
 
 public class TestWebappClassLoaderWeaving extends TomcatBaseTest {
 
@@ -60,11 +60,10 @@ public class TestWebappClassLoaderWeaving extends 
TomcatBaseTest {
 
 @AfterClass
 public static void tearDownClass() throws Exception {
-
-FileUtils.deleteDirectory(new File(WEBAPP_DOC_BASE));
-
+ExpandWar.delete(new File(WEBAPP_DOC_BASE));
 }
 
+
 private Tomcat tomcat;
 private Context context;
 private WebappClassLoaderBase loader;
diff --git a/test/org/apache/catalina/session/FileStoreTest.java 
b/test/org/apache/catalina/session/FileStoreTest.java
index c827562bcb..4b80b389ac 

[tomcat] branch 8.5.x updated: Use correct import

2023-09-15 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 08e93f6822 Use correct import
08e93f6822 is described below

commit 08e93f682218510ae85a587594fbd5796f1f6729
Author: Mark Thomas 
AuthorDate: Fri Sep 15 10:40:08 2023 +0100

Use correct import
---
 java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java | 1 +
 1 file changed, 1 insertion(+)

diff --git a/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java 
b/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java
index 4cd7f7adfb..d05397ab16 100644
--- a/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java
+++ b/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java
@@ -16,6 +16,7 @@
  */
 package org.apache.coyote.http11.filters;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 


-
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: Use correct import

2023-09-15 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 21411a21f9 Use correct import
21411a21f9 is described below

commit 21411a21f98752acda872e3a00fe1882419a97bc
Author: Mark Thomas 
AuthorDate: Fri Sep 15 10:40:08 2023 +0100

Use correct import
---
 java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java 
b/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java
index c7a6f27a48..5879bbf2ea 100644
--- a/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java
+++ b/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java
@@ -16,6 +16,7 @@
  */
 package org.apache.coyote.http11.filters;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.nio.ByteBuffer;
@@ -30,7 +31,6 @@ import org.apache.coyote.Response;
 import org.apache.coyote.http11.HttpOutputBuffer;
 import org.apache.coyote.http11.OutputFilter;
 import org.apache.tomcat.util.buf.HexUtils;
-import org.apache.tomcat.util.http.fileupload.ByteArrayOutputStream;
 
 /**
  * Chunked output filter.


-
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: Use correct import

2023-09-15 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 7302b1cf69 Use correct import
7302b1cf69 is described below

commit 7302b1cf696ef5a17d2bbea0bb965ac1d4128c11
Author: Mark Thomas 
AuthorDate: Fri Sep 15 10:40:08 2023 +0100

Use correct import
---
 java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java 
b/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java
index c7a6f27a48..5879bbf2ea 100644
--- a/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java
+++ b/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java
@@ -16,6 +16,7 @@
  */
 package org.apache.coyote.http11.filters;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.nio.ByteBuffer;
@@ -30,7 +31,6 @@ import org.apache.coyote.Response;
 import org.apache.coyote.http11.HttpOutputBuffer;
 import org.apache.coyote.http11.OutputFilter;
 import org.apache.tomcat.util.buf.HexUtils;
-import org.apache.tomcat.util.http.fileupload.ByteArrayOutputStream;
 
 /**
  * Chunked output filter.


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



[tomcat] branch main updated: Use correct import

2023-09-15 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 af522a175b Use correct import
af522a175b is described below

commit af522a175b7920b3af6387575e1ded7790d14dbc
Author: Mark Thomas 
AuthorDate: Fri Sep 15 10:40:08 2023 +0100

Use correct import
---
 java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java 
b/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java
index c7a6f27a48..5879bbf2ea 100644
--- a/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java
+++ b/java/org/apache/coyote/http11/filters/ChunkedOutputFilter.java
@@ -16,6 +16,7 @@
  */
 package org.apache.coyote.http11.filters;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.nio.ByteBuffer;
@@ -30,7 +31,6 @@ import org.apache.coyote.Response;
 import org.apache.coyote.http11.HttpOutputBuffer;
 import org.apache.coyote.http11.OutputFilter;
 import org.apache.tomcat.util.buf.HexUtils;
-import org.apache.tomcat.util.http.fileupload.ByteArrayOutputStream;
 
 /**
  * Chunked output filter.


-
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: Use more appropriate utility class

2023-09-15 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 b4f27c7c17 Use more appropriate utility class
b4f27c7c17 is described below

commit b4f27c7c17d783e66e2b0ef7f9fd8f6fb8679e95
Author: Mark Thomas 
AuthorDate: Fri Sep 15 10:37:40 2023 +0100

Use more appropriate utility class
---
 java/org/apache/catalina/valves/ProxyErrorReportValve.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/valves/ProxyErrorReportValve.java 
b/java/org/apache/catalina/valves/ProxyErrorReportValve.java
index 7220ffabf0..175ae8e330 100644
--- a/java/org/apache/catalina/valves/ProxyErrorReportValve.java
+++ b/java/org/apache/catalina/valves/ProxyErrorReportValve.java
@@ -31,12 +31,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
+import org.apache.catalina.util.IOTools;
 import org.apache.coyote.ActionCode;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.descriptor.web.ErrorPage;
-import org.apache.tomcat.util.http.fileupload.IOUtils;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
@@ -218,7 +218,7 @@ public class ProxyErrorReportValve extends ErrorReportValve 
{
 
response.setContentLength(httpURLConnection.getContentLength());
 OutputStream outputStream = response.getOutputStream();
 InputStream inputStream = url.openStream();
-IOUtils.copy(inputStream, outputStream);
+IOTools.flow(inputStream, outputStream);
 } catch (URISyntaxException | IOException | 
IllegalArgumentException e) {
 if (log.isDebugEnabled()) {
 log.debug("Proxy error to " + urlString, e);


-
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: Use more appropriate utility class

2023-09-15 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 4d38ebf48c Use more appropriate utility class
4d38ebf48c is described below

commit 4d38ebf48c1d3a40520919d82be54a2f8de77f6c
Author: Mark Thomas 
AuthorDate: Fri Sep 15 10:37:40 2023 +0100

Use more appropriate utility class
---
 java/org/apache/catalina/valves/ProxyErrorReportValve.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/valves/ProxyErrorReportValve.java 
b/java/org/apache/catalina/valves/ProxyErrorReportValve.java
index 7220ffabf0..175ae8e330 100644
--- a/java/org/apache/catalina/valves/ProxyErrorReportValve.java
+++ b/java/org/apache/catalina/valves/ProxyErrorReportValve.java
@@ -31,12 +31,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
+import org.apache.catalina.util.IOTools;
 import org.apache.coyote.ActionCode;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.descriptor.web.ErrorPage;
-import org.apache.tomcat.util.http.fileupload.IOUtils;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
@@ -218,7 +218,7 @@ public class ProxyErrorReportValve extends ErrorReportValve 
{
 
response.setContentLength(httpURLConnection.getContentLength());
 OutputStream outputStream = response.getOutputStream();
 InputStream inputStream = url.openStream();
-IOUtils.copy(inputStream, outputStream);
+IOTools.flow(inputStream, outputStream);
 } catch (URISyntaxException | IOException | 
IllegalArgumentException e) {
 if (log.isDebugEnabled()) {
 log.debug("Proxy error to " + urlString, e);


-
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: Use more appropriate utility class

2023-09-15 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 f3b152ce47 Use more appropriate utility class
f3b152ce47 is described below

commit f3b152ce47a1f0875e8e0ebe12c50d1188d73a55
Author: Mark Thomas 
AuthorDate: Fri Sep 15 10:37:40 2023 +0100

Use more appropriate utility class
---
 java/org/apache/catalina/valves/ProxyErrorReportValve.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/valves/ProxyErrorReportValve.java 
b/java/org/apache/catalina/valves/ProxyErrorReportValve.java
index 949390bcf7..3371ee55e6 100644
--- a/java/org/apache/catalina/valves/ProxyErrorReportValve.java
+++ b/java/org/apache/catalina/valves/ProxyErrorReportValve.java
@@ -31,12 +31,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
+import org.apache.catalina.util.IOTools;
 import org.apache.coyote.ActionCode;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.descriptor.web.ErrorPage;
-import org.apache.tomcat.util.http.fileupload.IOUtils;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
@@ -209,7 +209,7 @@ public class ProxyErrorReportValve extends ErrorReportValve 
{
 
response.setContentLength(httpURLConnection.getContentLength());
 OutputStream outputStream = response.getOutputStream();
 InputStream inputStream = url.openStream();
-IOUtils.copy(inputStream, outputStream);
+IOTools.flow(inputStream, outputStream);
 } catch (URISyntaxException | IOException | 
IllegalArgumentException e) {
 if (log.isDebugEnabled()) {
 log.debug("Proxy error to " + urlString, e);


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



[tomcat] branch main updated: Use more appropriate utility class

2023-09-15 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 c1c5b87543 Use more appropriate utility class
c1c5b87543 is described below

commit c1c5b8754355d74a96fcd8d0e5dcfcc396e9bcd1
Author: Mark Thomas 
AuthorDate: Fri Sep 15 10:37:40 2023 +0100

Use more appropriate utility class
---
 java/org/apache/catalina/valves/ProxyErrorReportValve.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/valves/ProxyErrorReportValve.java 
b/java/org/apache/catalina/valves/ProxyErrorReportValve.java
index 949390bcf7..3371ee55e6 100644
--- a/java/org/apache/catalina/valves/ProxyErrorReportValve.java
+++ b/java/org/apache/catalina/valves/ProxyErrorReportValve.java
@@ -31,12 +31,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
+import org.apache.catalina.util.IOTools;
 import org.apache.coyote.ActionCode;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.descriptor.web.ErrorPage;
-import org.apache.tomcat.util.http.fileupload.IOUtils;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
@@ -209,7 +209,7 @@ public class ProxyErrorReportValve extends ErrorReportValve 
{
 
response.setContentLength(httpURLConnection.getContentLength());
 OutputStream outputStream = response.getOutputStream();
 InputStream inputStream = url.openStream();
-IOUtils.copy(inputStream, outputStream);
+IOTools.flow(inputStream, outputStream);
 } catch (URISyntaxException | IOException | 
IllegalArgumentException e) {
 if (log.isDebugEnabled()) {
 log.debug("Proxy error to " + urlString, e);


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



[Bug 66676] WebSocket session complains about closed state when calling close()

2023-09-15 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=66676

--- Comment #9 from Mark Thomas  ---
Ping. It has been two months. This is heading towards being closed as
WORKSFORME.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[Bug 66706] The name of jar is different with the artifactId in the pom file

2023-09-15 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=66706

Mark Thomas  changed:

   What|Removed |Added

 Status|NEEDINFO|RESOLVED
 Resolution|--- |WONTFIX

--- Comment #2 from Mark Thomas  ---
No response to request for information so closing. This can always be reopened
to provide the requested information if the problem persists.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[Bug 67235] NPE (NullPointerException) occurs in AsyncContextImpl.decrementInProgressAsyncCount after version 10.1.12.

2023-09-15 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=67235

Mark Thomas  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED

--- Comment #7 from Mark Thomas  ---
The checks for duplicate error handling have been simplified and expanded. This
addresses the behaviour I observed while investigating this bug.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
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: Prevent duplicate error handling.

2023-09-15 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 e60d1d2f8a Prevent duplicate error handling.
e60d1d2f8a is described below

commit e60d1d2f8a0b09224a46cfbb3a2f9225f110f469
Author: Mark Thomas 
AuthorDate: Thu Sep 14 20:27:18 2023 +0100

Prevent duplicate error handling.

When an error occurs during asynchronous processing, ensure that the error
handling process is only triggered once per asynchronous cycle.
---
 .../org/apache/catalina/core/AsyncContextImpl.java |  6 +++
 java/org/apache/coyote/AsyncStateMachine.java  | 49 +-
 test/org/apache/coyote/http2/TestAsyncError.java   |  2 +-
 webapps/docs/changelog.xml |  5 +++
 4 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/java/org/apache/catalina/core/AsyncContextImpl.java 
b/java/org/apache/catalina/core/AsyncContextImpl.java
index c7a8f1d878..ba982cbff1 100644
--- a/java/org/apache/catalina/core/AsyncContextImpl.java
+++ b/java/org/apache/catalina/core/AsyncContextImpl.java
@@ -73,6 +73,7 @@ public class AsyncContextImpl implements AsyncContext, 
AsyncContextCallback {
 private long timeout = -1;
 private AsyncEvent event = null;
 private volatile Request request;
+AtomicBoolean hasProcessedError = new AtomicBoolean(false);
 
 public AsyncContextImpl(Request request) {
 if (log.isDebugEnabled()) {
@@ -279,6 +280,7 @@ public class AsyncContextImpl implements AsyncContext, 
AsyncContextCallback {
 request = null;
 clearServletRequestResponse();
 timeout = -1;
+hasProcessedError.set(false);
 }
 
 private void clearServletRequestResponse() {
@@ -377,6 +379,10 @@ public class AsyncContextImpl implements AsyncContext, 
AsyncContextCallback {
 
 
 public void setErrorState(Throwable t, boolean fireOnError) {
+if (!hasProcessedError.compareAndSet(false, true)) {
+// Skip duplicate error processing
+return;
+}
 if (t != null) {
 request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
 }
diff --git a/java/org/apache/coyote/AsyncStateMachine.java 
b/java/org/apache/coyote/AsyncStateMachine.java
index fcac6102f3..ba9822318e 100644
--- a/java/org/apache/coyote/AsyncStateMachine.java
+++ b/java/org/apache/coyote/AsyncStateMachine.java
@@ -186,14 +186,12 @@ public class AsyncStateMachine {
  */
 private final AtomicLong generation = new AtomicLong(0);
 /*
- * Error processing should only be triggered once per async generation. 
These fields track the last generation of
- * async processing for which error processing was triggered and are used 
to ensure that the second and subsequent
- * attempts to trigger async error processing for a given generation are 
NO-OPs.
+ * Error processing should only be triggered once per async generation. 
This field tracks whether the async
+ * processing has entered the error state during this async cycle.
  *
  * Guarded by this
  */
-private long lastErrorGeneration = -1;
-private long lastErrorGenerationMust = -1;
+private boolean hasProcessedError = false;
 
 // Need this to fire listener on complete
 private AsyncContextCallback asyncCtxt = null;
@@ -422,23 +420,6 @@ public class AsyncStateMachine {
 Request request = processor.getRequest();
 boolean containerThread = (request != null && 
request.isRequestThread());
 
-// Ensure the error processing is only started once per generation
-if (lastErrorGeneration == getCurrentGeneration()) {
-if (state == AsyncState.MUST_ERROR && containerThread && 
lastErrorGenerationMust != getCurrentGeneration()) {
-// This is the first container thread call after state was set 
to MUST_ERROR so don't skip
-lastErrorGenerationMust = getCurrentGeneration();
-} else {
-// Duplicate call. Skip.
-if (log.isDebugEnabled()) {
-
log.debug(sm.getString("asyncStateMachine.asyncError.skip"));
-}
-return false;
-}
-} else {
-// First call for this generation, don't skip.
-lastErrorGeneration = getCurrentGeneration();
-}
-
 if (log.isDebugEnabled()) {
 log.debug(sm.getString("asyncStateMachine.asyncError.start"));
 }
@@ -446,14 +427,23 @@ public class AsyncStateMachine {
 clearNonBlockingListeners();
 if (state == AsyncState.STARTING) {
 updateState(AsyncState.MUST_ERROR);
-} else if (state == AsyncState.DISPATCHED) {
-// Async error handling has moved processing back into an async
-// state. Need to increment in progress 

[tomcat] branch 9.0.x updated: Prevent duplicate error handling.

2023-09-15 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 a9c886766a Prevent duplicate error handling.
a9c886766a is described below

commit a9c886766a0e5edc187cab3d420e8e3c0ffbf8e9
Author: Mark Thomas 
AuthorDate: Thu Sep 14 20:27:18 2023 +0100

Prevent duplicate error handling.

When an error occurs during asynchronous processing, ensure that the error
handling process is only triggered once per asynchronous cycle.
---
 .../org/apache/catalina/core/AsyncContextImpl.java |  6 +++
 java/org/apache/coyote/AsyncStateMachine.java  | 49 +-
 test/org/apache/coyote/http2/TestAsyncError.java   |  2 +-
 webapps/docs/changelog.xml |  5 +++
 4 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/java/org/apache/catalina/core/AsyncContextImpl.java 
b/java/org/apache/catalina/core/AsyncContextImpl.java
index 56ef57ae44..e4466c7d08 100644
--- a/java/org/apache/catalina/core/AsyncContextImpl.java
+++ b/java/org/apache/catalina/core/AsyncContextImpl.java
@@ -73,6 +73,7 @@ public class AsyncContextImpl implements AsyncContext, 
AsyncContextCallback {
 private long timeout = -1;
 private AsyncEvent event = null;
 private volatile Request request;
+AtomicBoolean hasProcessedError = new AtomicBoolean(false);
 
 public AsyncContextImpl(Request request) {
 if (log.isDebugEnabled()) {
@@ -279,6 +280,7 @@ public class AsyncContextImpl implements AsyncContext, 
AsyncContextCallback {
 request = null;
 clearServletRequestResponse();
 timeout = -1;
+hasProcessedError.set(false);
 }
 
 private void clearServletRequestResponse() {
@@ -377,6 +379,10 @@ public class AsyncContextImpl implements AsyncContext, 
AsyncContextCallback {
 
 
 public void setErrorState(Throwable t, boolean fireOnError) {
+if (!hasProcessedError.compareAndSet(false, true)) {
+// Skip duplicate error processing
+return;
+}
 if (t != null) {
 request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
 }
diff --git a/java/org/apache/coyote/AsyncStateMachine.java 
b/java/org/apache/coyote/AsyncStateMachine.java
index c81f93735c..a651def252 100644
--- a/java/org/apache/coyote/AsyncStateMachine.java
+++ b/java/org/apache/coyote/AsyncStateMachine.java
@@ -186,14 +186,12 @@ class AsyncStateMachine {
  */
 private final AtomicLong generation = new AtomicLong(0);
 /*
- * Error processing should only be triggered once per async generation. 
These fields track the last generation of
- * async processing for which error processing was triggered and are used 
to ensure that the second and subsequent
- * attempts to trigger async error processing for a given generation are 
NO-OPs.
+ * Error processing should only be triggered once per async generation. 
This field tracks whether the async
+ * processing has entered the error state during this async cycle.
  *
  * Guarded by this
  */
-private long lastErrorGeneration = -1;
-private long lastErrorGenerationMust = -1;
+private boolean hasProcessedError = false;
 
 // Need this to fire listener on complete
 private AsyncContextCallback asyncCtxt = null;
@@ -422,23 +420,6 @@ class AsyncStateMachine {
 Request request = processor.getRequest();
 boolean containerThread = (request != null && 
request.isRequestThread());
 
-// Ensure the error processing is only started once per generation
-if (lastErrorGeneration == getCurrentGeneration()) {
-if (state == AsyncState.MUST_ERROR && containerThread && 
lastErrorGenerationMust != getCurrentGeneration()) {
-// This is the first container thread call after state was set 
to MUST_ERROR so don't skip
-lastErrorGenerationMust = getCurrentGeneration();
-} else {
-// Duplicate call. Skip.
-if (log.isDebugEnabled()) {
-
log.debug(sm.getString("asyncStateMachine.asyncError.skip"));
-}
-return false;
-}
-} else {
-// First call for this generation, don't skip.
-lastErrorGeneration = getCurrentGeneration();
-}
-
 if (log.isDebugEnabled()) {
 log.debug(sm.getString("asyncStateMachine.asyncError.start"));
 }
@@ -446,14 +427,23 @@ class AsyncStateMachine {
 clearNonBlockingListeners();
 if (state == AsyncState.STARTING) {
 updateState(AsyncState.MUST_ERROR);
-} else if (state == AsyncState.DISPATCHED) {
-// Async error handling has moved processing back into an async
-// state. Need to increment in progress count as it will 

[tomcat] branch main updated: Prevent duplicate error handling.

2023-09-15 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 d2fe5aa858 Prevent duplicate error handling.
d2fe5aa858 is described below

commit d2fe5aa8587151884300226193d22a7f08cd1d1d
Author: Mark Thomas 
AuthorDate: Thu Sep 14 20:27:18 2023 +0100

Prevent duplicate error handling.

When an error occurs during asynchronous processing, ensure that the error
handling process is only triggered once per asynchronous cycle.
---
 .../org/apache/catalina/core/AsyncContextImpl.java |  6 +++
 java/org/apache/coyote/AsyncStateMachine.java  | 49 +-
 test/org/apache/coyote/http2/TestAsyncError.java   |  2 +-
 webapps/docs/changelog.xml |  5 +++
 4 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/java/org/apache/catalina/core/AsyncContextImpl.java 
b/java/org/apache/catalina/core/AsyncContextImpl.java
index f956800455..0af2ffcf9b 100644
--- a/java/org/apache/catalina/core/AsyncContextImpl.java
+++ b/java/org/apache/catalina/core/AsyncContextImpl.java
@@ -73,6 +73,7 @@ public class AsyncContextImpl implements AsyncContext, 
AsyncContextCallback {
 private long timeout = -1;
 private AsyncEvent event = null;
 private volatile Request request;
+AtomicBoolean hasProcessedError = new AtomicBoolean(false);
 
 public AsyncContextImpl(Request request) {
 if (log.isDebugEnabled()) {
@@ -279,6 +280,7 @@ public class AsyncContextImpl implements AsyncContext, 
AsyncContextCallback {
 request = null;
 clearServletRequestResponse();
 timeout = -1;
+hasProcessedError.set(false);
 }
 
 private void clearServletRequestResponse() {
@@ -377,6 +379,10 @@ public class AsyncContextImpl implements AsyncContext, 
AsyncContextCallback {
 
 
 public void setErrorState(Throwable t, boolean fireOnError) {
+if (!hasProcessedError.compareAndSet(false, true)) {
+// Skip duplicate error processing
+return;
+}
 if (t != null) {
 request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
 }
diff --git a/java/org/apache/coyote/AsyncStateMachine.java 
b/java/org/apache/coyote/AsyncStateMachine.java
index 04270925a3..be322c6426 100644
--- a/java/org/apache/coyote/AsyncStateMachine.java
+++ b/java/org/apache/coyote/AsyncStateMachine.java
@@ -183,14 +183,12 @@ class AsyncStateMachine {
  */
 private final AtomicLong generation = new AtomicLong(0);
 /*
- * Error processing should only be triggered once per async generation. 
These fields track the last generation of
- * async processing for which error processing was triggered and are used 
to ensure that the second and subsequent
- * attempts to trigger async error processing for a given generation are 
NO-OPs.
+ * Error processing should only be triggered once per async generation. 
This field tracks whether the async
+ * processing has entered the error state during this async cycle.
  *
  * Guarded by this
  */
-private long lastErrorGeneration = -1;
-private long lastErrorGenerationMust = -1;
+private boolean hasProcessedError = false;
 
 // Need this to fire listener on complete
 private AsyncContextCallback asyncCtxt = null;
@@ -425,23 +423,6 @@ class AsyncStateMachine {
 Request request = processor.getRequest();
 boolean containerThread = (request != null && 
request.isRequestThread());
 
-// Ensure the error processing is only started once per generation
-if (lastErrorGeneration == getCurrentGeneration()) {
-if (state == AsyncState.MUST_ERROR && containerThread && 
lastErrorGenerationMust != getCurrentGeneration()) {
-// This is the first container thread call after state was set 
to MUST_ERROR so don't skip
-lastErrorGenerationMust = getCurrentGeneration();
-} else {
-// Duplicate call. Skip.
-if (log.isDebugEnabled()) {
-
log.debug(sm.getString("asyncStateMachine.asyncError.skip"));
-}
-return false;
-}
-} else {
-// First call for this generation, don't skip.
-lastErrorGeneration = getCurrentGeneration();
-}
-
 if (log.isDebugEnabled()) {
 log.debug(sm.getString("asyncStateMachine.asyncError.start"));
 }
@@ -449,14 +430,23 @@ class AsyncStateMachine {
 clearNonBlockingListeners();
 if (state == AsyncState.STARTING) {
 updateState(AsyncState.MUST_ERROR);
-} else if (state == AsyncState.DISPATCHED) {
-// Async error handling has moved processing back into an async
-// state. Need to increment in progress count as it will decrement

[tomcat] branch 10.1.x updated: Prevent duplicate error handling.

2023-09-15 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 4f8c6efc35 Prevent duplicate error handling.
4f8c6efc35 is described below

commit 4f8c6efc35cfd2636df382456feb49f1aa07845f
Author: Mark Thomas 
AuthorDate: Thu Sep 14 20:27:18 2023 +0100

Prevent duplicate error handling.

When an error occurs during asynchronous processing, ensure that the error
handling process is only triggered once per asynchronous cycle.
---
 .../org/apache/catalina/core/AsyncContextImpl.java |  6 +++
 java/org/apache/coyote/AsyncStateMachine.java  | 49 +-
 test/org/apache/coyote/http2/TestAsyncError.java   |  2 +-
 webapps/docs/changelog.xml |  5 +++
 4 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/java/org/apache/catalina/core/AsyncContextImpl.java 
b/java/org/apache/catalina/core/AsyncContextImpl.java
index cceddd1e6a..1e4b03741d 100644
--- a/java/org/apache/catalina/core/AsyncContextImpl.java
+++ b/java/org/apache/catalina/core/AsyncContextImpl.java
@@ -74,6 +74,7 @@ public class AsyncContextImpl implements AsyncContext, 
AsyncContextCallback {
 private long timeout = -1;
 private AsyncEvent event = null;
 private volatile Request request;
+AtomicBoolean hasProcessedError = new AtomicBoolean(false);
 
 public AsyncContextImpl(Request request) {
 if (log.isDebugEnabled()) {
@@ -280,6 +281,7 @@ public class AsyncContextImpl implements AsyncContext, 
AsyncContextCallback {
 request = null;
 clearServletRequestResponse();
 timeout = -1;
+hasProcessedError.set(false);
 }
 
 private void clearServletRequestResponse() {
@@ -378,6 +380,10 @@ public class AsyncContextImpl implements AsyncContext, 
AsyncContextCallback {
 
 
 public void setErrorState(Throwable t, boolean fireOnError) {
+if (!hasProcessedError.compareAndSet(false, true)) {
+// Skip duplicate error processing
+return;
+}
 if (t != null) {
 request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
 }
diff --git a/java/org/apache/coyote/AsyncStateMachine.java 
b/java/org/apache/coyote/AsyncStateMachine.java
index c81f93735c..a651def252 100644
--- a/java/org/apache/coyote/AsyncStateMachine.java
+++ b/java/org/apache/coyote/AsyncStateMachine.java
@@ -186,14 +186,12 @@ class AsyncStateMachine {
  */
 private final AtomicLong generation = new AtomicLong(0);
 /*
- * Error processing should only be triggered once per async generation. 
These fields track the last generation of
- * async processing for which error processing was triggered and are used 
to ensure that the second and subsequent
- * attempts to trigger async error processing for a given generation are 
NO-OPs.
+ * Error processing should only be triggered once per async generation. 
This field tracks whether the async
+ * processing has entered the error state during this async cycle.
  *
  * Guarded by this
  */
-private long lastErrorGeneration = -1;
-private long lastErrorGenerationMust = -1;
+private boolean hasProcessedError = false;
 
 // Need this to fire listener on complete
 private AsyncContextCallback asyncCtxt = null;
@@ -422,23 +420,6 @@ class AsyncStateMachine {
 Request request = processor.getRequest();
 boolean containerThread = (request != null && 
request.isRequestThread());
 
-// Ensure the error processing is only started once per generation
-if (lastErrorGeneration == getCurrentGeneration()) {
-if (state == AsyncState.MUST_ERROR && containerThread && 
lastErrorGenerationMust != getCurrentGeneration()) {
-// This is the first container thread call after state was set 
to MUST_ERROR so don't skip
-lastErrorGenerationMust = getCurrentGeneration();
-} else {
-// Duplicate call. Skip.
-if (log.isDebugEnabled()) {
-
log.debug(sm.getString("asyncStateMachine.asyncError.skip"));
-}
-return false;
-}
-} else {
-// First call for this generation, don't skip.
-lastErrorGeneration = getCurrentGeneration();
-}
-
 if (log.isDebugEnabled()) {
 log.debug(sm.getString("asyncStateMachine.asyncError.start"));
 }
@@ -446,14 +427,23 @@ class AsyncStateMachine {
 clearNonBlockingListeners();
 if (state == AsyncState.STARTING) {
 updateState(AsyncState.MUST_ERROR);
-} else if (state == AsyncState.DISPATCHED) {
-// Async error handling has moved processing back into an async
-// state. Need to increment in progress count as it will