Re: [VOTE] Release Apache Tomcat 8.5.92

2023-08-10 Thread Han Li



> On Aug 9, 2023, at 20:03, Mark Thomas  wrote:
> 
> The proposed Apache Tomcat 8.5.92 release is now available for voting.
> 
> The notable changes compared to 8.5.91 are:
> 
> - Refactor HTTP/2 implementation to reduce pinning when using virtual
>   threads.
> 
> -  Fix a NullPointerException when flushing batched WebSocket messages
>  with compression enabled using permessage-deflate.
> 
> - Update Tomcat Native to 1.2.38 to pick up Windows binaries built
>  with OpenSSL 1.1.1v
> 
> Along with lots of other bug fixes and improvements.
> 
> For full details, see the changelog:
> https://nightlies.apache.org/tomcat/tomcat-8.5.x/docs/changelog.html
> 
> It can be obtained from:
> https://dist.apache.org/repos/dist/dev/tomcat/tomcat-8/v8.5.92/
> 
> The Maven staging repo is:
> https://repository.apache.org/content/repositories/orgapachetomcat-1450
> 
> The tag is:
> https://github.com/apache/tomcat/tree/8.5.92/
> 90f385149d4c1492e7d50412b19b9fad55bd70a9
> 
> The proposed 8.5.92 release is:
> [ ] Broken - do not release
> [X] Stable - go ahead and release as 8.5.92 (stable)
Tests pass

Han

> 
> -
> 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



Re: [PROPOSAL] Drop support for HTTP/2 server push

2023-08-10 Thread Han Li



> On Aug 10, 2023, at 20:02, Mark Thomas  wrote:
> 
> Hi all,
> 
> HTTP/2 server push never really took off and has/is being dropped by the 
> major browsers. More details in this blog post:
> 
> https://developer.chrome.com/blog/removing-push/
> 
> I'd like to propose deprecating support for server push in Tomcat 10.1.x and 
> removing in Tomcat 11.
+1

Han
> 
> The current Servlet API allows us to always return null from 
> HttpServletRequest.newPushBuilder
> 
> Separately, I have proposed deprecating the push API in the servlet spec for 
> removal in a future version.
> 
> Any objections to this proposal?
> 
> Mark
> 
> -
> 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



[Bug 66875] Handling async error after spring already handled error

2023-08-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=66875

Nils Kohrs  changed:

   What|Removed |Added

  Component|Catalina|Connectors

-- 
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 66875] New: Handling async error after spring already handled error

2023-08-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=66875

Bug ID: 66875
   Summary: Handling async error after spring already handled
error
   Product: Tomcat 10
   Version: 10.1.11
  Hardware: All
OS: All
Status: NEW
  Severity: normal
  Priority: P2
 Component: Catalina
  Assignee: dev@tomcat.apache.org
  Reporter: nils.ko...@gmail.com
  Target Milestone: --

First reported as bug on Spring
Boot(https://github.com/spring-projects/spring-boot/issues/36803). After some
investigation I've been redirected by the spring team to post the bug here.

Reproduction steps with spring boot(tested on version 3.0.0 and 3.1.2):

- Create spring initializr project with Kotlin and spring-boot-starter-web
- Add org.jetbrains.kotlinx:kotlinx-coroutines-reactor dependency
- Run following (Kotlin) code

---
@SpringBootApplication
class DemoApplication
fun main(args: Array) {
runApplication(*args)
}
@RestController
class Controller {
@GetMapping("suspend")
suspend fun errorScenario() {
throw IllegalStateException("Double exception handling")
}
}

@ControllerAdvice
class ExceptionHandler : ResponseEntityExceptionHandler() {
@ExceptionHandler(Exception::class)
fun handleUnexpectedException(
ex: Exception,
request: WebRequest
): ResponseEntity? {
return handleException(
ErrorResponseException(
HttpStatus.INTERNAL_SERVER_ERROR,
ProblemDetail.forStatus(500),
ex
), request
)
}
}
---

When calling the /suspend endpoint (with postman) spring will catch the
exception and create a response. If that response is has status 500 it will
also set "jakarta.servlet.error.exception" with the caught exception.
Because of this, this code in
org.apache.catalina.connector.CoyoteAdapter.asyncDispatch(...) will trigger a
second exception handling.

---
if (request.isAsyncDispatching()) {
   
connector.getService().getContainer().getPipeline().getFirst().invoke(request,
response);
Throwable t = (Throwable)
request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
if (t != null) {
asyncConImpl.setErrorState(t, true);
}
}
---

The result of this is that two response bodies, including body size, will be
generated and returned. Postman will show that the request had a problem. This
is because there is more data than the first body size reports, which is an
invalid http response. Sniffing the response you can actually see the full
response:

---
HTTP/1.1 500
Content-Type: application/problem+json
Transfer-Encoding: chunked
Date: Tue, 08 Aug 2023 09:26:30 GMT
Connection: close

59
{"type":"about:blank","title":"Internal Server
Error","status":500,"instance":"/suspend"}
6c
{"timestamp":"2023-08-08T09:26:30.705+00:00","status":500,"error":"Internal
Server Error","path":"/suspend"}
---

When calling the endpoint with chrome it will generate following error message,
but only return a single response:
s.e.ErrorMvcAutoConfiguration$StaticView : Cannot render error page for request
[/suspend] as the response has already been committed. As a result, the
response may have the wrong status code.

This bug goes for me far too deep into the inner workings and I don't know if
this is a tomcat bug or spring should just not set the the request attribute
"jakarta.servlet.error.exception". It is however notable that when using
another server(jetty, undertow) underneath spring this issue does not occur.
And that is probably why the spring team send me here.

-- 
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 9.0.x updated: Consistent synchronization - reported by Coverity

2023-08-10 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 b131b93b19 Consistent synchronization - reported by Coverity
b131b93b19 is described below

commit b131b93b191c83d024b86014da5a16128eb460fe
Author: Mark Thomas 
AuthorDate: Thu Aug 10 15:44:21 2023 +0100

Consistent synchronization - reported by Coverity
---
 java/org/apache/catalina/core/StandardService.java | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/core/StandardService.java 
b/java/org/apache/catalina/core/StandardService.java
index 7b9a0e601b..a194c3dd6e 100644
--- a/java/org/apache/catalina/core/StandardService.java
+++ b/java/org/apache/catalina/core/StandardService.java
@@ -266,7 +266,10 @@ public class StandardService extends LifecycleMBeanBase 
implements Service {
  */
 @Override
 public Connector[] findConnectors() {
-return connectors;
+synchronized (connectorsLock) {
+// shallow copy
+return connectors.clone();
+}
 }
 
 


-
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: Consistent synchronization - reported by Coverity

2023-08-10 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 b4f218f644 Consistent synchronization - reported by Coverity
b4f218f644 is described below

commit b4f218f644a7347596c55a153038630621fb896a
Author: Mark Thomas 
AuthorDate: Thu Aug 10 15:44:21 2023 +0100

Consistent synchronization - reported by Coverity
---
 java/org/apache/catalina/core/StandardService.java | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/core/StandardService.java 
b/java/org/apache/catalina/core/StandardService.java
index 7b9a0e601b..a194c3dd6e 100644
--- a/java/org/apache/catalina/core/StandardService.java
+++ b/java/org/apache/catalina/core/StandardService.java
@@ -266,7 +266,10 @@ public class StandardService extends LifecycleMBeanBase 
implements Service {
  */
 @Override
 public Connector[] findConnectors() {
-return connectors;
+synchronized (connectorsLock) {
+// shallow copy
+return connectors.clone();
+}
 }
 
 


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



[tomcat] branch main updated: Consistent synchronization - reported by Coverity

2023-08-10 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 39c388b518 Consistent synchronization - reported by Coverity
39c388b518 is described below

commit 39c388b51817d346031189a8a942340b6e46b940
Author: Mark Thomas 
AuthorDate: Thu Aug 10 15:44:21 2023 +0100

Consistent synchronization - reported by Coverity
---
 java/org/apache/catalina/core/StandardService.java | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/core/StandardService.java 
b/java/org/apache/catalina/core/StandardService.java
index 7b9a0e601b..a194c3dd6e 100644
--- a/java/org/apache/catalina/core/StandardService.java
+++ b/java/org/apache/catalina/core/StandardService.java
@@ -266,7 +266,10 @@ public class StandardService extends LifecycleMBeanBase 
implements Service {
  */
 @Override
 public Connector[] findConnectors() {
-return connectors;
+synchronized (connectorsLock) {
+// shallow copy
+return connectors.clone();
+}
 }
 
 


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



[tomcat] branch main updated: Consistent synchronization - reported by Coverity

2023-08-10 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 5edb5a1560 Consistent synchronization - reported by Coverity
5edb5a1560 is described below

commit 5edb5a156083a30b5158dcba027f86e7c625ccf5
Author: Mark Thomas 
AuthorDate: Thu Aug 10 15:36:28 2023 +0100

Consistent synchronization - reported by Coverity
---
 java/org/apache/catalina/core/StandardService.java | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/catalina/core/StandardService.java 
b/java/org/apache/catalina/core/StandardService.java
index c52dca88f4..7b9a0e601b 100644
--- a/java/org/apache/catalina/core/StandardService.java
+++ b/java/org/apache/catalina/core/StandardService.java
@@ -241,11 +241,13 @@ public class StandardService extends LifecycleMBeanBase 
implements Service {
 
 
 public ObjectName[] getConnectorNames() {
-ObjectName results[] = new ObjectName[connectors.length];
-for (int i = 0; i < results.length; i++) {
-results[i] = connectors[i].getObjectName();
+synchronized (connectorsLock) {
+ObjectName results[] = new ObjectName[connectors.length];
+for (int i = 0; i < results.length; i++) {
+results[i] = connectors[i].getObjectName();
+}
+return results;
 }
-return results;
 }
 
 


-
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: Consistent synchronization - reported by Coverity

2023-08-10 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 4f39b02eed Consistent synchronization - reported by Coverity
4f39b02eed is described below

commit 4f39b02eed0897fcbf2491e0e93dacd022506da1
Author: Mark Thomas 
AuthorDate: Thu Aug 10 15:36:28 2023 +0100

Consistent synchronization - reported by Coverity
---
 java/org/apache/catalina/core/StandardService.java | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/catalina/core/StandardService.java 
b/java/org/apache/catalina/core/StandardService.java
index c615b75204..c6216f6174 100644
--- a/java/org/apache/catalina/core/StandardService.java
+++ b/java/org/apache/catalina/core/StandardService.java
@@ -242,11 +242,13 @@ public class StandardService extends LifecycleMBeanBase 
implements Service {
 
 
 public ObjectName[] getConnectorNames() {
-ObjectName results[] = new ObjectName[connectors.length];
-for (int i = 0; i < results.length; i++) {
-results[i] = connectors[i].getObjectName();
+synchronized (connectorsLock) {
+ObjectName results[] = new ObjectName[connectors.length];
+for (int i = 0; i < results.length; i++) {
+results[i] = connectors[i].getObjectName();
+}
+return results;
 }
-return results;
 }
 
 


-
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: Consistent synchronization - reported by Coverity

2023-08-10 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 4324a122da Consistent synchronization - reported by Coverity
4324a122da is described below

commit 4324a122da4df743a7d9a90e0264928fc4dc41eb
Author: Mark Thomas 
AuthorDate: Thu Aug 10 15:36:28 2023 +0100

Consistent synchronization - reported by Coverity
---
 java/org/apache/catalina/core/StandardService.java | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/catalina/core/StandardService.java 
b/java/org/apache/catalina/core/StandardService.java
index c52dca88f4..7b9a0e601b 100644
--- a/java/org/apache/catalina/core/StandardService.java
+++ b/java/org/apache/catalina/core/StandardService.java
@@ -241,11 +241,13 @@ public class StandardService extends LifecycleMBeanBase 
implements Service {
 
 
 public ObjectName[] getConnectorNames() {
-ObjectName results[] = new ObjectName[connectors.length];
-for (int i = 0; i < results.length; i++) {
-results[i] = connectors[i].getObjectName();
+synchronized (connectorsLock) {
+ObjectName results[] = new ObjectName[connectors.length];
+for (int i = 0; i < results.length; i++) {
+results[i] = connectors[i].getObjectName();
+}
+return results;
 }
-return results;
 }
 
 


-
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: Consistent synchronization - reported by Coverity

2023-08-10 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 cceb5b9bd1 Consistent synchronization - reported by Coverity
cceb5b9bd1 is described below

commit cceb5b9bd1913a08f4754df921f131c7b6844120
Author: Mark Thomas 
AuthorDate: Thu Aug 10 15:36:28 2023 +0100

Consistent synchronization - reported by Coverity
---
 java/org/apache/catalina/core/StandardService.java | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/catalina/core/StandardService.java 
b/java/org/apache/catalina/core/StandardService.java
index c52dca88f4..7b9a0e601b 100644
--- a/java/org/apache/catalina/core/StandardService.java
+++ b/java/org/apache/catalina/core/StandardService.java
@@ -241,11 +241,13 @@ public class StandardService extends LifecycleMBeanBase 
implements Service {
 
 
 public ObjectName[] getConnectorNames() {
-ObjectName results[] = new ObjectName[connectors.length];
-for (int i = 0; i < results.length; i++) {
-results[i] = connectors[i].getObjectName();
+synchronized (connectorsLock) {
+ObjectName results[] = new ObjectName[connectors.length];
+for (int i = 0; i < results.length; i++) {
+results[i] = connectors[i].getObjectName();
+}
+return results;
 }
-return results;
 }
 
 


-
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: Refactor to use CopyOnWriteArrayList rather than hand-crafted equivalent

2023-08-10 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 030e748852 Refactor to use CopyOnWriteArrayList rather than 
hand-crafted equivalent
030e748852 is described below

commit 030e748852cd7018929cf87cbe1021f97ff0abed
Author: Mark Thomas 
AuthorDate: Thu Aug 10 15:25:47 2023 +0100

Refactor to use CopyOnWriteArrayList rather than hand-crafted equivalent

In response to a concurrency issue raised by Coverity
---
 java/org/apache/catalina/core/StandardContext.java | 62 +-
 1 file changed, 12 insertions(+), 50 deletions(-)

diff --git a/java/org/apache/catalina/core/StandardContext.java 
b/java/org/apache/catalina/core/StandardContext.java
index d038e18460..d621fe7d45 100644
--- a/java/org/apache/catalina/core/StandardContext.java
+++ b/java/org/apache/catalina/core/StandardContext.java
@@ -202,12 +202,10 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
 
 
 /**
- * The set of application listener class names configured for this 
application, in the order they were encountered
- * in the resulting merged web.xml file.
+ * The list of unique application listener class names configured for this 
application, in the order they were
+ * encountered in the resulting merged web.xml file.
  */
-private String applicationListeners[] = new String[0];
-
-private final Object applicationListenersLock = new Object();
+private CopyOnWriteArrayList applicationListeners = new 
CopyOnWriteArrayList<>();
 
 /**
  * The set of application listeners that are required to have limited 
access to ServletContext methods. See Servlet
@@ -2682,21 +2680,11 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
  */
 @Override
 public void addApplicationListener(String listener) {
-
-synchronized (applicationListenersLock) {
-String results[] = new String[applicationListeners.length + 1];
-for (int i = 0; i < applicationListeners.length; i++) {
-if (listener.equals(applicationListeners[i])) {
-log.info(sm.getString("standardContext.duplicateListener", 
listener));
-return;
-}
-results[i] = applicationListeners[i];
-}
-results[applicationListeners.length] = listener;
-applicationListeners = results;
+if (applicationListeners.addIfAbsent(listener)) {
+fireContainerEvent("addApplicationListener", listener);
+} else {
+log.info(sm.getString("standardContext.duplicateListener", 
listener));
 }
-fireContainerEvent("addApplicationListener", listener);
-
 }
 
 
@@ -3198,7 +3186,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
  */
 @Override
 public String[] findApplicationListeners() {
-return applicationListeners;
+return applicationListeners.toArray(new String[0]);
 }
 
 
@@ -3611,36 +3599,10 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
  */
 @Override
 public void removeApplicationListener(String listener) {
-
-synchronized (applicationListenersLock) {
-
-// Make sure this listener is currently present
-int n = -1;
-for (int i = 0; i < applicationListeners.length; i++) {
-if (applicationListeners[i].equals(listener)) {
-n = i;
-break;
-}
-}
-if (n < 0) {
-return;
-}
-
-// Remove the specified listener
-int j = 0;
-String results[] = new String[applicationListeners.length - 1];
-for (int i = 0; i < applicationListeners.length; i++) {
-if (i != n) {
-results[j++] = applicationListeners[i];
-}
-}
-applicationListeners = results;
-
+if (applicationListeners.remove(listener)) {
+// Inform interested listeners if the specified listener was 
present and has been removed
+fireContainerEvent("removeApplicationListener", listener);
 }
-
-// Inform interested listeners
-fireContainerEvent("removeApplicationListener", listener);
-
 }
 
 
@@ -5359,7 +5321,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
 // Bugzilla 32867
 distributable = false;
 
-applicationListeners = new String[0];
+applicationListeners.clear();
 applicationEventListenersList.clear();
 applicationLifecycleListenersObjects = new Object[0];
 jspConfigDescriptor = null;



[tomcat] branch 8.5.x updated: Refactor to use CopyOnWriteArrayList rather than hand-crafted equivalent

2023-08-10 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 8b7141e9bb Refactor to use CopyOnWriteArrayList rather than 
hand-crafted equivalent
8b7141e9bb is described below

commit 8b7141e9bbec2900096456b01b8b6371350cbc80
Author: Mark Thomas 
AuthorDate: Thu Aug 10 15:25:47 2023 +0100

Refactor to use CopyOnWriteArrayList rather than hand-crafted equivalent

In response to a concurrency issue raised by Coverity
---
 java/org/apache/catalina/core/StandardContext.java | 62 +-
 1 file changed, 12 insertions(+), 50 deletions(-)

diff --git a/java/org/apache/catalina/core/StandardContext.java 
b/java/org/apache/catalina/core/StandardContext.java
index 02f3f7a796..de33471e5f 100644
--- a/java/org/apache/catalina/core/StandardContext.java
+++ b/java/org/apache/catalina/core/StandardContext.java
@@ -202,12 +202,10 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
 
 
 /**
- * The set of application listener class names configured for this 
application, in the order they were encountered
- * in the resulting merged web.xml file.
+ * The list of unique application listener class names configured for this 
application, in the order they were
+ * encountered in the resulting merged web.xml file.
  */
-private String applicationListeners[] = new String[0];
-
-private final Object applicationListenersLock = new Object();
+private CopyOnWriteArrayList applicationListeners = new 
CopyOnWriteArrayList<>();
 
 /**
  * The set of application listeners that are required to have limited 
access to ServletContext methods. See Servlet
@@ -2643,21 +2641,11 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
  */
 @Override
 public void addApplicationListener(String listener) {
-
-synchronized (applicationListenersLock) {
-String results[] = new String[applicationListeners.length + 1];
-for (int i = 0; i < applicationListeners.length; i++) {
-if (listener.equals(applicationListeners[i])) {
-log.info(sm.getString("standardContext.duplicateListener", 
listener));
-return;
-}
-results[i] = applicationListeners[i];
-}
-results[applicationListeners.length] = listener;
-applicationListeners = results;
+if (applicationListeners.addIfAbsent(listener)) {
+fireContainerEvent("addApplicationListener", listener);
+} else {
+log.info(sm.getString("standardContext.duplicateListener", 
listener));
 }
-fireContainerEvent("addApplicationListener", listener);
-
 }
 
 
@@ -3170,7 +3158,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
  */
 @Override
 public String[] findApplicationListeners() {
-return applicationListeners;
+return applicationListeners.toArray(new String[0]);
 }
 
 
@@ -3577,36 +3565,10 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
  */
 @Override
 public void removeApplicationListener(String listener) {
-
-synchronized (applicationListenersLock) {
-
-// Make sure this listener is currently present
-int n = -1;
-for (int i = 0; i < applicationListeners.length; i++) {
-if (applicationListeners[i].equals(listener)) {
-n = i;
-break;
-}
-}
-if (n < 0) {
-return;
-}
-
-// Remove the specified listener
-int j = 0;
-String results[] = new String[applicationListeners.length - 1];
-for (int i = 0; i < applicationListeners.length; i++) {
-if (i != n) {
-results[j++] = applicationListeners[i];
-}
-}
-applicationListeners = results;
-
+if (applicationListeners.remove(listener)) {
+// Inform interested listeners if the specified listener was 
present and has been removed
+fireContainerEvent("removeApplicationListener", listener);
 }
-
-// Inform interested listeners
-fireContainerEvent("removeApplicationListener", listener);
-
 }
 
 
@@ -5339,7 +5301,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
 // Bugzilla 32867
 distributable = false;
 
-applicationListeners = new String[0];
+applicationListeners.clear();
 applicationEventListenersList.clear();
 applicationLifecycleListenersObjects = new Object[0];
 jspConfigDescriptor = null;



[tomcat] branch 10.1.x updated: Refactor to use CopyOnWriteArrayList rather than hand-crafted equivalent

2023-08-10 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 2eeb45f80e Refactor to use CopyOnWriteArrayList rather than 
hand-crafted equivalent
2eeb45f80e is described below

commit 2eeb45f80e17b95f5986e0be2cc29bd6fd165801
Author: Mark Thomas 
AuthorDate: Thu Aug 10 15:25:47 2023 +0100

Refactor to use CopyOnWriteArrayList rather than hand-crafted equivalent

In response to a concurrency issue raised by Coverity
---
 java/org/apache/catalina/core/StandardContext.java | 62 +-
 1 file changed, 12 insertions(+), 50 deletions(-)

diff --git a/java/org/apache/catalina/core/StandardContext.java 
b/java/org/apache/catalina/core/StandardContext.java
index 5f9cbc1e89..6d76f8987c 100644
--- a/java/org/apache/catalina/core/StandardContext.java
+++ b/java/org/apache/catalina/core/StandardContext.java
@@ -201,12 +201,10 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
 
 
 /**
- * The set of application listener class names configured for this 
application, in the order they were encountered
- * in the resulting merged web.xml file.
+ * The list of unique application listener class names configured for this 
application, in the order they were
+ * encountered in the resulting merged web.xml file.
  */
-private String applicationListeners[] = new String[0];
-
-private final Object applicationListenersLock = new Object();
+private CopyOnWriteArrayList applicationListeners = new 
CopyOnWriteArrayList<>();
 
 /**
  * The set of application listeners that are required to have limited 
access to ServletContext methods. See Servlet
@@ -2722,21 +2720,11 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
  */
 @Override
 public void addApplicationListener(String listener) {
-
-synchronized (applicationListenersLock) {
-String results[] = new String[applicationListeners.length + 1];
-for (int i = 0; i < applicationListeners.length; i++) {
-if (listener.equals(applicationListeners[i])) {
-log.info(sm.getString("standardContext.duplicateListener", 
listener));
-return;
-}
-results[i] = applicationListeners[i];
-}
-results[applicationListeners.length] = listener;
-applicationListeners = results;
+if (applicationListeners.addIfAbsent(listener)) {
+fireContainerEvent("addApplicationListener", listener);
+} else {
+log.info(sm.getString("standardContext.duplicateListener", 
listener));
 }
-fireContainerEvent("addApplicationListener", listener);
-
 }
 
 
@@ -3225,7 +3213,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
  */
 @Override
 public String[] findApplicationListeners() {
-return applicationListeners;
+return applicationListeners.toArray(new String[0]);
 }
 
 
@@ -3576,36 +3564,10 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
  */
 @Override
 public void removeApplicationListener(String listener) {
-
-synchronized (applicationListenersLock) {
-
-// Make sure this listener is currently present
-int n = -1;
-for (int i = 0; i < applicationListeners.length; i++) {
-if (applicationListeners[i].equals(listener)) {
-n = i;
-break;
-}
-}
-if (n < 0) {
-return;
-}
-
-// Remove the specified listener
-int j = 0;
-String results[] = new String[applicationListeners.length - 1];
-for (int i = 0; i < applicationListeners.length; i++) {
-if (i != n) {
-results[j++] = applicationListeners[i];
-}
-}
-applicationListeners = results;
-
+if (applicationListeners.remove(listener)) {
+// Inform interested listeners if the specified listener was 
present and has been removed
+fireContainerEvent("removeApplicationListener", listener);
 }
-
-// Inform interested listeners
-fireContainerEvent("removeApplicationListener", listener);
-
 }
 
 
@@ -5305,7 +5267,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
 // Bugzilla 32867
 distributable = false;
 
-applicationListeners = new String[0];
+applicationListeners.clear();
 applicationEventListenersList.clear();
 applicationLifecycleListenersObjects = new Object[0];
 jspConfigDescriptor = null;



[tomcat] branch main updated: Refactor to use CopyOnWriteArrayList rather than hand-crafted equivalent

2023-08-10 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 9c09f9abfb Refactor to use CopyOnWriteArrayList rather than 
hand-crafted equivalent
9c09f9abfb is described below

commit 9c09f9abfb60910b054005968e0dd359ae2a1dd8
Author: Mark Thomas 
AuthorDate: Thu Aug 10 15:25:47 2023 +0100

Refactor to use CopyOnWriteArrayList rather than hand-crafted equivalent

In response to a concurrency issue raised by Coverity
---
 java/org/apache/catalina/core/StandardContext.java | 62 +-
 1 file changed, 12 insertions(+), 50 deletions(-)

diff --git a/java/org/apache/catalina/core/StandardContext.java 
b/java/org/apache/catalina/core/StandardContext.java
index 3b7616050b..9ed5ce6e4b 100644
--- a/java/org/apache/catalina/core/StandardContext.java
+++ b/java/org/apache/catalina/core/StandardContext.java
@@ -197,12 +197,10 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
 
 
 /**
- * The set of application listener class names configured for this 
application, in the order they were encountered
- * in the resulting merged web.xml file.
+ * The list of unique application listener class names configured for this 
application, in the order they were
+ * encountered in the resulting merged web.xml file.
  */
-private String applicationListeners[] = new String[0];
-
-private final Object applicationListenersLock = new Object();
+private CopyOnWriteArrayList applicationListeners = new 
CopyOnWriteArrayList<>();
 
 /**
  * The set of application listeners that are required to have limited 
access to ServletContext methods. See Servlet
@@ -2701,21 +2699,11 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
  */
 @Override
 public void addApplicationListener(String listener) {
-
-synchronized (applicationListenersLock) {
-String results[] = new String[applicationListeners.length + 1];
-for (int i = 0; i < applicationListeners.length; i++) {
-if (listener.equals(applicationListeners[i])) {
-log.info(sm.getString("standardContext.duplicateListener", 
listener));
-return;
-}
-results[i] = applicationListeners[i];
-}
-results[applicationListeners.length] = listener;
-applicationListeners = results;
+if (applicationListeners.addIfAbsent(listener)) {
+fireContainerEvent("addApplicationListener", listener);
+} else {
+log.info(sm.getString("standardContext.duplicateListener", 
listener));
 }
-fireContainerEvent("addApplicationListener", listener);
-
 }
 
 
@@ -3204,7 +3192,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
  */
 @Override
 public String[] findApplicationListeners() {
-return applicationListeners;
+return applicationListeners.toArray(new String[0]);
 }
 
 
@@ -3555,36 +3543,10 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
  */
 @Override
 public void removeApplicationListener(String listener) {
-
-synchronized (applicationListenersLock) {
-
-// Make sure this listener is currently present
-int n = -1;
-for (int i = 0; i < applicationListeners.length; i++) {
-if (applicationListeners[i].equals(listener)) {
-n = i;
-break;
-}
-}
-if (n < 0) {
-return;
-}
-
-// Remove the specified listener
-int j = 0;
-String results[] = new String[applicationListeners.length - 1];
-for (int i = 0; i < applicationListeners.length; i++) {
-if (i != n) {
-results[j++] = applicationListeners[i];
-}
-}
-applicationListeners = results;
-
+if (applicationListeners.remove(listener)) {
+// Inform interested listeners if the specified listener was 
present and has been removed
+fireContainerEvent("removeApplicationListener", listener);
 }
-
-// Inform interested listeners
-fireContainerEvent("removeApplicationListener", listener);
-
 }
 
 
@@ -5273,7 +5235,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
 // Bugzilla 32867
 distributable = false;
 
-applicationListeners = new String[0];
+applicationListeners.clear();
 applicationEventListenersList.clear();
 applicationLifecycleListenersObjects = new Object[0];
 jspConfigDescriptor = null;



[tomcat] branch 10.1.x updated: Refactor to use a common lock for filters

2023-08-10 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 e2f59f3ca3 Refactor to use a common lock for filters
e2f59f3ca3 is described below

commit e2f59f3ca3f73f06bc44dc3fe6eacebd397bcd49
Author: Mark Thomas 
AuthorDate: Thu Aug 10 14:25:58 2023 +0100

Refactor to use a common lock for filters
---
 java/org/apache/catalina/core/StandardContext.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/core/StandardContext.java 
b/java/org/apache/catalina/core/StandardContext.java
index b80cd0a001..5f9cbc1e89 100644
--- a/java/org/apache/catalina/core/StandardContext.java
+++ b/java/org/apache/catalina/core/StandardContext.java
@@ -361,7 +361,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
 /**
  * The set of filter configurations (and associated filter instances) we 
have initialized, keyed by filter name.
  */
-private Map filterConfigs = new 
HashMap<>();
+private Map filterConfigs = new 
HashMap<>(); // Guarded by filterDefs
 
 
 /**
@@ -4298,7 +4298,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
 }
 // Instantiate and record a FilterConfig for each defined filter
 boolean ok = true;
-synchronized (filterConfigs) {
+synchronized (filterDefs) {
 filterConfigs.clear();
 for (Entry entry : filterDefs.entrySet()) {
 String name = entry.getKey();
@@ -4333,7 +4333,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
 }
 
 // Release all Filter and FilterConfig instances
-synchronized (filterConfigs) {
+synchronized (filterDefs) {
 for (Entry entry : 
filterConfigs.entrySet()) {
 if (getLogger().isDebugEnabled()) {
 getLogger().debug(" Stopping filter '" + entry.getKey() + 
"'");


-
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: Refactor to use a common lock for filters

2023-08-10 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 c19baa0926 Refactor to use a common lock for filters
c19baa0926 is described below

commit c19baa0926981db3dcfc770fdc3b5249518cf54d
Author: Mark Thomas 
AuthorDate: Thu Aug 10 14:25:58 2023 +0100

Refactor to use a common lock for filters
---
 java/org/apache/catalina/core/StandardContext.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/core/StandardContext.java 
b/java/org/apache/catalina/core/StandardContext.java
index b89bd9110f..02f3f7a796 100644
--- a/java/org/apache/catalina/core/StandardContext.java
+++ b/java/org/apache/catalina/core/StandardContext.java
@@ -361,7 +361,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
 /**
  * The set of filter configurations (and associated filter instances) we 
have initialized, keyed by filter name.
  */
-private HashMap filterConfigs = new 
HashMap<>();
+private HashMap filterConfigs = new 
HashMap<>(); // Guarded by filterDefs
 
 
 /**
@@ -4317,7 +4317,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
 }
 // Instantiate and record a FilterConfig for each defined filter
 boolean ok = true;
-synchronized (filterConfigs) {
+synchronized (filterDefs) {
 filterConfigs.clear();
 for (Entry entry : filterDefs.entrySet()) {
 String name = entry.getKey();
@@ -4352,7 +4352,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
 }
 
 // Release all Filter and FilterConfig instances
-synchronized (filterConfigs) {
+synchronized (filterDefs) {
 for (Entry entry : 
filterConfigs.entrySet()) {
 if (getLogger().isDebugEnabled()) {
 getLogger().debug(" Stopping filter '" + entry.getKey() + 
"'");


-
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: Refactor to use a common lock for filters

2023-08-10 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 497b8d3512 Refactor to use a common lock for filters
497b8d3512 is described below

commit 497b8d3512fcdf99558fd0a2898a0b742af340e9
Author: Mark Thomas 
AuthorDate: Thu Aug 10 14:25:58 2023 +0100

Refactor to use a common lock for filters
---
 java/org/apache/catalina/core/StandardContext.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/core/StandardContext.java 
b/java/org/apache/catalina/core/StandardContext.java
index 3d03b12d97..d038e18460 100644
--- a/java/org/apache/catalina/core/StandardContext.java
+++ b/java/org/apache/catalina/core/StandardContext.java
@@ -362,7 +362,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
 /**
  * The set of filter configurations (and associated filter instances) we 
have initialized, keyed by filter name.
  */
-private Map filterConfigs = new 
HashMap<>();
+private Map filterConfigs = new 
HashMap<>(); // Guarded by filterDefs
 
 
 /**
@@ -4338,7 +4338,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
 }
 // Instantiate and record a FilterConfig for each defined filter
 boolean ok = true;
-synchronized (filterConfigs) {
+synchronized (filterDefs) {
 filterConfigs.clear();
 for (Entry entry : filterDefs.entrySet()) {
 String name = entry.getKey();
@@ -4373,7 +4373,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
 }
 
 // Release all Filter and FilterConfig instances
-synchronized (filterConfigs) {
+synchronized (filterDefs) {
 for (Entry entry : 
filterConfigs.entrySet()) {
 if (getLogger().isDebugEnabled()) {
 getLogger().debug(" Stopping filter '" + entry.getKey() + 
"'");


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



[tomcat] branch main updated: Refactor to use a common lock for filters

2023-08-10 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 81208e5ca0 Refactor to use a common lock for filters
81208e5ca0 is described below

commit 81208e5ca044141df4409c410030e45f18966ae4
Author: Mark Thomas 
AuthorDate: Thu Aug 10 14:25:58 2023 +0100

Refactor to use a common lock for filters
---
 java/org/apache/catalina/core/StandardContext.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/core/StandardContext.java 
b/java/org/apache/catalina/core/StandardContext.java
index 58b97c6d8f..3b7616050b 100644
--- a/java/org/apache/catalina/core/StandardContext.java
+++ b/java/org/apache/catalina/core/StandardContext.java
@@ -357,7 +357,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
 /**
  * The set of filter configurations (and associated filter instances) we 
have initialized, keyed by filter name.
  */
-private Map filterConfigs = new 
HashMap<>();
+private Map filterConfigs = new 
HashMap<>(); // Guarded by filterDefs
 
 
 /**
@@ -4269,7 +4269,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
 }
 // Instantiate and record a FilterConfig for each defined filter
 boolean ok = true;
-synchronized (filterConfigs) {
+synchronized (filterDefs) {
 filterConfigs.clear();
 for (Entry entry : filterDefs.entrySet()) {
 String name = entry.getKey();
@@ -4304,7 +4304,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
 }
 
 // Release all Filter and FilterConfig instances
-synchronized (filterConfigs) {
+synchronized (filterDefs) {
 for (Entry entry : 
filterConfigs.entrySet()) {
 if (getLogger().isDebugEnabled()) {
 getLogger().debug(" Stopping filter '" + entry.getKey() + 
"'");


-
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: Ensure access to children is always sync'd - identified by Coverity

2023-08-10 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 b970fd9262 Ensure access to children is always sync'd - identified by 
Coverity
b970fd9262 is described below

commit b970fd9262b62aa67c875ef6c2f79a9ae162e9fc
Author: Mark Thomas 
AuthorDate: Thu Aug 10 14:08:30 2023 +0100

Ensure access to children is always sync'd - identified by Coverity
---
 java/org/apache/catalina/core/ContainerBase.java | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/catalina/core/ContainerBase.java 
b/java/org/apache/catalina/core/ContainerBase.java
index 610baf054c..7c2a883eb3 100644
--- a/java/org/apache/catalina/core/ContainerBase.java
+++ b/java/org/apache/catalina/core/ContainerBase.java
@@ -1206,11 +1206,15 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 return keyProperties.toString();
 }
 
+
 public ObjectName[] getChildren() {
-List names = new ArrayList<>(children.size());
-for (Container next : children.values()) {
-if (next instanceof ContainerBase) {
-names.add(((ContainerBase) next).getObjectName());
+List names;
+synchronized (children) {
+names = new ArrayList<>(children.size());
+for (Container next : children.values()) {
+if (next instanceof ContainerBase) {
+names.add(((ContainerBase) next).getObjectName());
+}
 }
 }
 return names.toArray(new ObjectName[0]);


-
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: Ensure access to children is always sync'd - identified by Coverity

2023-08-10 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 ad88bb6b13 Ensure access to children is always sync'd - identified by 
Coverity
ad88bb6b13 is described below

commit ad88bb6b13a0498204851bda5f65f6ca715c0ae4
Author: Mark Thomas 
AuthorDate: Thu Aug 10 14:08:30 2023 +0100

Ensure access to children is always sync'd - identified by Coverity
---
 java/org/apache/catalina/core/ContainerBase.java | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/catalina/core/ContainerBase.java 
b/java/org/apache/catalina/core/ContainerBase.java
index 7c30072d68..c9f51acc6e 100644
--- a/java/org/apache/catalina/core/ContainerBase.java
+++ b/java/org/apache/catalina/core/ContainerBase.java
@@ -1196,11 +1196,15 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 return keyProperties.toString();
 }
 
+
 public ObjectName[] getChildren() {
-List names = new ArrayList<>(children.size());
-for (Container next : children.values()) {
-if (next instanceof ContainerBase) {
-names.add(next.getObjectName());
+List names;
+synchronized (children) {
+names = new ArrayList<>(children.size());
+for (Container next : children.values()) {
+if (next instanceof ContainerBase) {
+names.add(next.getObjectName());
+}
 }
 }
 return names.toArray(new ObjectName[0]);


-
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: Ensure access to children is always sync'd - identified by Coverity

2023-08-10 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 102b61d410 Ensure access to children is always sync'd - identified by 
Coverity
102b61d410 is described below

commit 102b61d41042ab2f220ae5e6650ae2a27ac6d428
Author: Mark Thomas 
AuthorDate: Thu Aug 10 14:08:30 2023 +0100

Ensure access to children is always sync'd - identified by Coverity
---
 java/org/apache/catalina/core/ContainerBase.java | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/catalina/core/ContainerBase.java 
b/java/org/apache/catalina/core/ContainerBase.java
index 7c30072d68..c9f51acc6e 100644
--- a/java/org/apache/catalina/core/ContainerBase.java
+++ b/java/org/apache/catalina/core/ContainerBase.java
@@ -1196,11 +1196,15 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 return keyProperties.toString();
 }
 
+
 public ObjectName[] getChildren() {
-List names = new ArrayList<>(children.size());
-for (Container next : children.values()) {
-if (next instanceof ContainerBase) {
-names.add(next.getObjectName());
+List names;
+synchronized (children) {
+names = new ArrayList<>(children.size());
+for (Container next : children.values()) {
+if (next instanceof ContainerBase) {
+names.add(next.getObjectName());
+}
 }
 }
 return names.toArray(new ObjectName[0]);


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



[tomcat] branch main updated: Ensure access to children is always sync'd - identified by Coverity

2023-08-10 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 8a5adbca61 Ensure access to children is always sync'd - identified by 
Coverity
8a5adbca61 is described below

commit 8a5adbca614a5a5bb56d67633da03d186a775e74
Author: Mark Thomas 
AuthorDate: Thu Aug 10 14:08:30 2023 +0100

Ensure access to children is always sync'd - identified by Coverity
---
 java/org/apache/catalina/core/ContainerBase.java | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/catalina/core/ContainerBase.java 
b/java/org/apache/catalina/core/ContainerBase.java
index d7fa461628..7e4c1fe550 100644
--- a/java/org/apache/catalina/core/ContainerBase.java
+++ b/java/org/apache/catalina/core/ContainerBase.java
@@ -1163,11 +1163,15 @@ public abstract class ContainerBase extends 
LifecycleMBeanBase implements Contai
 return keyProperties.toString();
 }
 
+
 public ObjectName[] getChildren() {
-List names = new ArrayList<>(children.size());
-for (Container next : children.values()) {
-if (next instanceof ContainerBase) {
-names.add(next.getObjectName());
+List names;
+synchronized (children) {
+names = new ArrayList<>(children.size());
+for (Container next : children.values()) {
+if (next instanceof ContainerBase) {
+names.add(next.getObjectName());
+}
 }
 }
 return names.toArray(new ObjectName[0]);


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



[PROPOSAL] Drop support for HTTP/2 server push

2023-08-10 Thread Mark Thomas

Hi all,

HTTP/2 server push never really took off and has/is being dropped by the 
major browsers. More details in this blog post:


https://developer.chrome.com/blog/removing-push/

I'd like to propose deprecating support for server push in Tomcat 10.1.x 
and removing in Tomcat 11.


The current Servlet API allows us to always return null from 
HttpServletRequest.newPushBuilder


Separately, I have proposed deprecating the push API in the servlet spec 
for removal in a future version.


Any objections to this proposal?

Mark

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



[tomcat] branch 8.5.x updated: Remove unnecessary code - coyoteRequest cannot be null

2023-08-10 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 5abfb3986f Remove unnecessary code - coyoteRequest cannot be null
5abfb3986f is described below

commit 5abfb3986f2944ef624e4027cf1bf11f2aeb4740
Author: Mark Thomas 
AuthorDate: Thu Aug 10 09:17:33 2023 +0100

Remove unnecessary code - coyoteRequest cannot be null
---
 java/org/apache/catalina/connector/InputBuffer.java | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/java/org/apache/catalina/connector/InputBuffer.java 
b/java/org/apache/catalina/connector/InputBuffer.java
index f65112646a..8c5fb836b4 100644
--- a/java/org/apache/catalina/connector/InputBuffer.java
+++ b/java/org/apache/catalina/connector/InputBuffer.java
@@ -309,9 +309,6 @@ public class InputBuffer extends Reader implements 
ByteChunk.ByteInputChannel, A
 if (closed) {
 return -1;
 }
-if (coyoteRequest == null) {
-return -1;
-}
 
 if (state == INITIAL_STATE) {
 state = BYTE_STATE;
@@ -551,10 +548,7 @@ public class InputBuffer extends Reader implements 
ByteChunk.ByteInputChannel, A
 return;
 }
 
-Charset charset = null;
-if (coyoteRequest != null) {
-charset = coyoteRequest.getCharset();
-}
+Charset charset = coyoteRequest.getCharset();
 
 if (charset == null) {
 if (enc == null) {


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



[tomcat] branch 9.0.x updated: Remove unnecessary code - coyoteRequest cannot be null

2023-08-10 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 646962853a Remove unnecessary code - coyoteRequest cannot be null
646962853a is described below

commit 646962853a3baa893c70414dcd15390c298b8be2
Author: Mark Thomas 
AuthorDate: Thu Aug 10 09:17:33 2023 +0100

Remove unnecessary code - coyoteRequest cannot be null
---
 java/org/apache/catalina/connector/InputBuffer.java | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/java/org/apache/catalina/connector/InputBuffer.java 
b/java/org/apache/catalina/connector/InputBuffer.java
index 00a95a8620..739507a0ea 100644
--- a/java/org/apache/catalina/connector/InputBuffer.java
+++ b/java/org/apache/catalina/connector/InputBuffer.java
@@ -301,9 +301,6 @@ public class InputBuffer extends Reader implements 
ByteChunk.ByteInputChannel, A
 if (closed) {
 return -1;
 }
-if (coyoteRequest == null) {
-return -1;
-}
 
 if (state == INITIAL_STATE) {
 state = BYTE_STATE;
@@ -531,10 +528,7 @@ public class InputBuffer extends Reader implements 
ByteChunk.ByteInputChannel, A
 return;
 }
 
-Charset charset = null;
-if (coyoteRequest != null) {
-charset = coyoteRequest.getCharset();
-}
+Charset charset = coyoteRequest.getCharset();
 
 if (charset == null) {
 charset = org.apache.coyote.Constants.DEFAULT_BODY_CHARSET;


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



[tomcat] branch 10.1.x updated: Remove unnecessary code - coyoteRequest cannot be null

2023-08-10 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 26d549102f Remove unnecessary code - coyoteRequest cannot be null
26d549102f is described below

commit 26d549102f015fc3e9138b9ac374dbda92d6fa35
Author: Mark Thomas 
AuthorDate: Thu Aug 10 09:17:33 2023 +0100

Remove unnecessary code - coyoteRequest cannot be null
---
 java/org/apache/catalina/connector/InputBuffer.java | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/java/org/apache/catalina/connector/InputBuffer.java 
b/java/org/apache/catalina/connector/InputBuffer.java
index 3bffaf74d1..97d7fbd87d 100644
--- a/java/org/apache/catalina/connector/InputBuffer.java
+++ b/java/org/apache/catalina/connector/InputBuffer.java
@@ -301,9 +301,6 @@ public class InputBuffer extends Reader implements 
ByteChunk.ByteInputChannel, A
 if (closed) {
 return -1;
 }
-if (coyoteRequest == null) {
-return -1;
-}
 
 if (state == INITIAL_STATE) {
 state = BYTE_STATE;
@@ -531,10 +528,7 @@ public class InputBuffer extends Reader implements 
ByteChunk.ByteInputChannel, A
 return;
 }
 
-Charset charset = null;
-if (coyoteRequest != null) {
-charset = coyoteRequest.getCharset();
-}
+Charset charset = coyoteRequest.getCharset();
 
 if (charset == null) {
 charset = org.apache.coyote.Constants.DEFAULT_BODY_CHARSET;


-
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: Add additional test used to confirm regression was fixed

2023-08-10 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 416c00b8e5 Add additional test used to confirm regression was fixed
416c00b8e5 is described below

commit 416c00b8e55524493b4b5075fea8433fef6923dc
Author: Mark Thomas 
AuthorDate: Thu Aug 10 08:55:45 2023 +0100

Add additional test used to confirm regression was fixed
---
 test/org/apache/catalina/mapper/TestMapper.java | 43 +
 1 file changed, 43 insertions(+)

diff --git a/test/org/apache/catalina/mapper/TestMapper.java 
b/test/org/apache/catalina/mapper/TestMapper.java
index c4dee6022a..37211e497a 100644
--- a/test/org/apache/catalina/mapper/TestMapper.java
+++ b/test/org/apache/catalina/mapper/TestMapper.java
@@ -509,4 +509,47 @@ public class TestMapper extends LoggingBaseTest {
 Assert.assertEquals("/foo/bar/bla", 
mappingData.contextPath.toString());
 }
 }
+
+
+@Test
+public void testCompareIgnoreCase() throws Exception {
+
+Mapper mapper = new Mapper();
+
+mapper.addHost("aaa", new String[0], createHost("a3"));
+mapper.addHost("", new String[0], createHost("a4"));
+mapper.addHost("a", new String[0], createHost("a5"));
+mapper.addHost("aa", new String[0], createHost("a6"));
+mapper.addHost("aaa", new String[0], createHost("a7"));
+
+mapper.setDefaultHostName("aaa");
+
+mapper.addContextVersion("aaa", createHost("a3"), "", "0", 
createContext("c3"), new String[0], null, null);
+mapper.addContextVersion("", createHost("a4"), "", "0", 
createContext("c4"), new String[0], null, null);
+mapper.addContextVersion("a", createHost("a5"), "", "0", 
createContext("c5"), new String[0], null, null);
+mapper.addContextVersion("aa", createHost("a6"), "", "0", 
createContext("c6"), new String[0], null, null);
+mapper.addContextVersion("aaa", createHost("a7"), "", "0", 
createContext("c7"), new String[0], null, null);
+
+mapper.addWrappers("aaa", "", "0", Arrays.asList(new 
WrapperMappingInfo[] {
+new WrapperMappingInfo("/", createWrapper("c3-default"), 
false, false) }));
+mapper.addWrappers("", "", "0", Arrays.asList(new 
WrapperMappingInfo[] {
+new WrapperMappingInfo("/", createWrapper("c4-default"), 
false, false) }));
+mapper.addWrappers("a", "", "0", Arrays.asList(new 
WrapperMappingInfo[] {
+new WrapperMappingInfo("/", createWrapper("c5-default"), 
false, false) }));
+mapper.addWrappers("aa", "", "0", Arrays.asList(new 
WrapperMappingInfo[] {
+new WrapperMappingInfo("/", createWrapper("c6-default"), 
false, false) }));
+mapper.addWrappers("aaa", "", "0", Arrays.asList(new 
WrapperMappingInfo[] {
+new WrapperMappingInfo("/", createWrapper("c7-default"), 
false, false) }));
+
+MappingData mappingData = new MappingData();
+MessageBytes hostMB = MessageBytes.newInstance();
+hostMB.setString("");
+MessageBytes uriMB = MessageBytes.newInstance();
+char[] uri = "/index.html".toCharArray();
+uriMB.setChars(uri, 0, uri.length);
+
+mapper.map(hostMB, uriMB, null, mappingData);
+
+Assert.assertEquals("a4", mappingData.host.getName());
+}
 }


-
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: Add additional test used to confirm regression was fixed

2023-08-10 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 33477a0a87 Add additional test used to confirm regression was fixed
33477a0a87 is described below

commit 33477a0a8766222a558897ec6716696583de39ff
Author: Mark Thomas 
AuthorDate: Thu Aug 10 08:55:45 2023 +0100

Add additional test used to confirm regression was fixed
---
 test/org/apache/catalina/mapper/TestMapper.java | 43 +
 1 file changed, 43 insertions(+)

diff --git a/test/org/apache/catalina/mapper/TestMapper.java 
b/test/org/apache/catalina/mapper/TestMapper.java
index c4dee6022a..37211e497a 100644
--- a/test/org/apache/catalina/mapper/TestMapper.java
+++ b/test/org/apache/catalina/mapper/TestMapper.java
@@ -509,4 +509,47 @@ public class TestMapper extends LoggingBaseTest {
 Assert.assertEquals("/foo/bar/bla", 
mappingData.contextPath.toString());
 }
 }
+
+
+@Test
+public void testCompareIgnoreCase() throws Exception {
+
+Mapper mapper = new Mapper();
+
+mapper.addHost("aaa", new String[0], createHost("a3"));
+mapper.addHost("", new String[0], createHost("a4"));
+mapper.addHost("a", new String[0], createHost("a5"));
+mapper.addHost("aa", new String[0], createHost("a6"));
+mapper.addHost("aaa", new String[0], createHost("a7"));
+
+mapper.setDefaultHostName("aaa");
+
+mapper.addContextVersion("aaa", createHost("a3"), "", "0", 
createContext("c3"), new String[0], null, null);
+mapper.addContextVersion("", createHost("a4"), "", "0", 
createContext("c4"), new String[0], null, null);
+mapper.addContextVersion("a", createHost("a5"), "", "0", 
createContext("c5"), new String[0], null, null);
+mapper.addContextVersion("aa", createHost("a6"), "", "0", 
createContext("c6"), new String[0], null, null);
+mapper.addContextVersion("aaa", createHost("a7"), "", "0", 
createContext("c7"), new String[0], null, null);
+
+mapper.addWrappers("aaa", "", "0", Arrays.asList(new 
WrapperMappingInfo[] {
+new WrapperMappingInfo("/", createWrapper("c3-default"), 
false, false) }));
+mapper.addWrappers("", "", "0", Arrays.asList(new 
WrapperMappingInfo[] {
+new WrapperMappingInfo("/", createWrapper("c4-default"), 
false, false) }));
+mapper.addWrappers("a", "", "0", Arrays.asList(new 
WrapperMappingInfo[] {
+new WrapperMappingInfo("/", createWrapper("c5-default"), 
false, false) }));
+mapper.addWrappers("aa", "", "0", Arrays.asList(new 
WrapperMappingInfo[] {
+new WrapperMappingInfo("/", createWrapper("c6-default"), 
false, false) }));
+mapper.addWrappers("aaa", "", "0", Arrays.asList(new 
WrapperMappingInfo[] {
+new WrapperMappingInfo("/", createWrapper("c7-default"), 
false, false) }));
+
+MappingData mappingData = new MappingData();
+MessageBytes hostMB = MessageBytes.newInstance();
+hostMB.setString("");
+MessageBytes uriMB = MessageBytes.newInstance();
+char[] uri = "/index.html".toCharArray();
+uriMB.setChars(uri, 0, uri.length);
+
+mapper.map(hostMB, uriMB, null, mappingData);
+
+Assert.assertEquals("a4", mappingData.host.getName());
+}
 }


-
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: Add additional test used to confirm regression was fixed

2023-08-10 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 e60e858193 Add additional test used to confirm regression was fixed
e60e858193 is described below

commit e60e858193a54b36c6fb17d0caf2b3968650ab21
Author: Mark Thomas 
AuthorDate: Thu Aug 10 08:55:45 2023 +0100

Add additional test used to confirm regression was fixed
---
 test/org/apache/catalina/mapper/TestMapper.java | 43 +
 1 file changed, 43 insertions(+)

diff --git a/test/org/apache/catalina/mapper/TestMapper.java 
b/test/org/apache/catalina/mapper/TestMapper.java
index a84069b6b7..03386b18c6 100644
--- a/test/org/apache/catalina/mapper/TestMapper.java
+++ b/test/org/apache/catalina/mapper/TestMapper.java
@@ -503,4 +503,47 @@ public class TestMapper extends LoggingBaseTest {
 Assert.assertEquals(context3, mappingData.context);
 }
 }
+
+
+@Test
+public void testCompareIgnoreCase() throws Exception {
+
+Mapper mapper = new Mapper();
+
+mapper.addHost("aaa", new String[0], createHost("a3"));
+mapper.addHost("", new String[0], createHost("a4"));
+mapper.addHost("a", new String[0], createHost("a5"));
+mapper.addHost("aa", new String[0], createHost("a6"));
+mapper.addHost("aaa", new String[0], createHost("a7"));
+
+mapper.setDefaultHostName("aaa");
+
+mapper.addContextVersion("aaa", createHost("a3"), "", "0", 
createContext("c3"), new String[0], null, null);
+mapper.addContextVersion("", createHost("a4"), "", "0", 
createContext("c4"), new String[0], null, null);
+mapper.addContextVersion("a", createHost("a5"), "", "0", 
createContext("c5"), new String[0], null, null);
+mapper.addContextVersion("aa", createHost("a6"), "", "0", 
createContext("c6"), new String[0], null, null);
+mapper.addContextVersion("aaa", createHost("a7"), "", "0", 
createContext("c7"), new String[0], null, null);
+
+mapper.addWrappers("aaa", "", "0", Arrays.asList(new 
WrapperMappingInfo[] {
+new WrapperMappingInfo("/", createWrapper("c3-default"), 
false, false) }));
+mapper.addWrappers("", "", "0", Arrays.asList(new 
WrapperMappingInfo[] {
+new WrapperMappingInfo("/", createWrapper("c4-default"), 
false, false) }));
+mapper.addWrappers("a", "", "0", Arrays.asList(new 
WrapperMappingInfo[] {
+new WrapperMappingInfo("/", createWrapper("c5-default"), 
false, false) }));
+mapper.addWrappers("aa", "", "0", Arrays.asList(new 
WrapperMappingInfo[] {
+new WrapperMappingInfo("/", createWrapper("c6-default"), 
false, false) }));
+mapper.addWrappers("aaa", "", "0", Arrays.asList(new 
WrapperMappingInfo[] {
+new WrapperMappingInfo("/", createWrapper("c7-default"), 
false, false) }));
+
+MappingData mappingData = new MappingData();
+MessageBytes hostMB = MessageBytes.newInstance();
+hostMB.setString("");
+MessageBytes uriMB = MessageBytes.newInstance();
+char[] uri = "/index.html".toCharArray();
+uriMB.setChars(uri, 0, uri.length);
+
+mapper.map(hostMB, uriMB, null, mappingData);
+
+Assert.assertEquals("a4", mappingData.host.getName());
+}
 }


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



[tomcat] branch main updated: Add additional test used to confirm regression was fixed

2023-08-10 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 d3b378594d Add additional test used to confirm regression was fixed
d3b378594d is described below

commit d3b378594dbfc70c5551857f7519525c9f48ab0b
Author: Mark Thomas 
AuthorDate: Thu Aug 10 08:55:45 2023 +0100

Add additional test used to confirm regression was fixed
---
 test/org/apache/catalina/mapper/TestMapper.java | 43 +
 1 file changed, 43 insertions(+)

diff --git a/test/org/apache/catalina/mapper/TestMapper.java 
b/test/org/apache/catalina/mapper/TestMapper.java
index a84069b6b7..03386b18c6 100644
--- a/test/org/apache/catalina/mapper/TestMapper.java
+++ b/test/org/apache/catalina/mapper/TestMapper.java
@@ -503,4 +503,47 @@ public class TestMapper extends LoggingBaseTest {
 Assert.assertEquals(context3, mappingData.context);
 }
 }
+
+
+@Test
+public void testCompareIgnoreCase() throws Exception {
+
+Mapper mapper = new Mapper();
+
+mapper.addHost("aaa", new String[0], createHost("a3"));
+mapper.addHost("", new String[0], createHost("a4"));
+mapper.addHost("a", new String[0], createHost("a5"));
+mapper.addHost("aa", new String[0], createHost("a6"));
+mapper.addHost("aaa", new String[0], createHost("a7"));
+
+mapper.setDefaultHostName("aaa");
+
+mapper.addContextVersion("aaa", createHost("a3"), "", "0", 
createContext("c3"), new String[0], null, null);
+mapper.addContextVersion("", createHost("a4"), "", "0", 
createContext("c4"), new String[0], null, null);
+mapper.addContextVersion("a", createHost("a5"), "", "0", 
createContext("c5"), new String[0], null, null);
+mapper.addContextVersion("aa", createHost("a6"), "", "0", 
createContext("c6"), new String[0], null, null);
+mapper.addContextVersion("aaa", createHost("a7"), "", "0", 
createContext("c7"), new String[0], null, null);
+
+mapper.addWrappers("aaa", "", "0", Arrays.asList(new 
WrapperMappingInfo[] {
+new WrapperMappingInfo("/", createWrapper("c3-default"), 
false, false) }));
+mapper.addWrappers("", "", "0", Arrays.asList(new 
WrapperMappingInfo[] {
+new WrapperMappingInfo("/", createWrapper("c4-default"), 
false, false) }));
+mapper.addWrappers("a", "", "0", Arrays.asList(new 
WrapperMappingInfo[] {
+new WrapperMappingInfo("/", createWrapper("c5-default"), 
false, false) }));
+mapper.addWrappers("aa", "", "0", Arrays.asList(new 
WrapperMappingInfo[] {
+new WrapperMappingInfo("/", createWrapper("c6-default"), 
false, false) }));
+mapper.addWrappers("aaa", "", "0", Arrays.asList(new 
WrapperMappingInfo[] {
+new WrapperMappingInfo("/", createWrapper("c7-default"), 
false, false) }));
+
+MappingData mappingData = new MappingData();
+MessageBytes hostMB = MessageBytes.newInstance();
+hostMB.setString("");
+MessageBytes uriMB = MessageBytes.newInstance();
+char[] uri = "/index.html".toCharArray();
+uriMB.setChars(uri, 0, uri.length);
+
+mapper.map(hostMB, uriMB, null, mappingData);
+
+Assert.assertEquals("a4", mappingData.host.getName());
+}
 }


-
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 a regression in 6353e786

2023-08-10 Thread lihan
This is an automated email from the ASF dual-hosted git repository.

lihan 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 5623b08fac Fix a regression in 6353e786
5623b08fac is described below

commit 5623b08fac963514c6793fda0aca743a876924a3
Author: lihan 
AuthorDate: Thu Aug 10 15:48:56 2023 +0800

Fix a regression in 6353e786
---
 java/org/apache/catalina/mapper/Mapper.java | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/catalina/mapper/Mapper.java 
b/java/org/apache/catalina/mapper/Mapper.java
index d2d3b4635e..a1f9d19257 100644
--- a/java/org/apache/catalina/mapper/Mapper.java
+++ b/java/org/apache/catalina/mapper/Mapper.java
@@ -1319,7 +1319,8 @@ public final class Mapper {
 private static int compare(CharChunk name, int start, int end, String 
compareTo) {
 int result = 0;
 char[] c = name.getBuffer();
-int len = compareTo.length();
+int compareLen = compareTo.length();
+int len = compareLen;
 if ((end - start) < len) {
 len = end - start;
 }
@@ -1333,9 +1334,9 @@ public final class Mapper {
 }
 }
 if (result == 0) {
-if (len > (end - start)) {
+if (compareLen > (end - start)) {
 result = -1;
-} else if (len < (end - start)) {
+} else if (compareLen < (end - start)) {
 result = 1;
 }
 }
@@ -1350,7 +1351,8 @@ public final class Mapper {
 private static int compareIgnoreCase(CharChunk name, int start, int end, 
String compareTo) {
 int result = 0;
 char[] c = name.getBuffer();
-int len = compareTo.length();
+int compareLen = compareTo.length();
+int len = compareLen;
 if ((end - start) < len) {
 len = end - start;
 }
@@ -1364,9 +1366,9 @@ public final class Mapper {
 }
 }
 if (result == 0) {
-if (len > (end - start)) {
+if (compareLen > (end - start)) {
 result = -1;
-} else if (len < (end - start)) {
+} else if (compareLen < (end - start)) {
 result = 1;
 }
 }


-
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 a regression in 6353e786

2023-08-10 Thread lihan
This is an automated email from the ASF dual-hosted git repository.

lihan 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 96ee000b9a Fix a regression in 6353e786
96ee000b9a is described below

commit 96ee000b9ad61d123bf3889e5152f668a36006ee
Author: lihan 
AuthorDate: Thu Aug 10 15:48:56 2023 +0800

Fix a regression in 6353e786
---
 java/org/apache/catalina/mapper/Mapper.java | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/catalina/mapper/Mapper.java 
b/java/org/apache/catalina/mapper/Mapper.java
index 70e428b45b..0a5690704b 100644
--- a/java/org/apache/catalina/mapper/Mapper.java
+++ b/java/org/apache/catalina/mapper/Mapper.java
@@ -1320,7 +1320,8 @@ public final class Mapper {
 private static int compare(CharChunk name, int start, int end, String 
compareTo) {
 int result = 0;
 char[] c = name.getBuffer();
-int len = compareTo.length();
+int compareLen = compareTo.length();
+int len = compareLen;
 if ((end - start) < len) {
 len = end - start;
 }
@@ -1334,9 +1335,9 @@ public final class Mapper {
 }
 }
 if (result == 0) {
-if (len > (end - start)) {
+if (compareLen > (end - start)) {
 result = -1;
-} else if (len < (end - start)) {
+} else if (compareLen < (end - start)) {
 result = 1;
 }
 }
@@ -1351,7 +1352,8 @@ public final class Mapper {
 private static int compareIgnoreCase(CharChunk name, int start, int end, 
String compareTo) {
 int result = 0;
 char[] c = name.getBuffer();
-int len = compareTo.length();
+int compareLen = compareTo.length();
+int len = compareLen;
 if ((end - start) < len) {
 len = end - start;
 }
@@ -1365,9 +1367,9 @@ public final class Mapper {
 }
 }
 if (result == 0) {
-if (len > (end - start)) {
+if (compareLen > (end - start)) {
 result = -1;
-} else if (len < (end - start)) {
+} else if (compareLen < (end - start)) {
 result = 1;
 }
 }


-
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 a regression in 6353e786

2023-08-10 Thread lihan
This is an automated email from the ASF dual-hosted git repository.

lihan 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 4d3f1bdbf3 Fix a regression in 6353e786
4d3f1bdbf3 is described below

commit 4d3f1bdbf3e7a626edfea97f1b2853ee27076264
Author: lihan 
AuthorDate: Thu Aug 10 15:48:56 2023 +0800

Fix a regression in 6353e786
---
 java/org/apache/catalina/mapper/Mapper.java | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/catalina/mapper/Mapper.java 
b/java/org/apache/catalina/mapper/Mapper.java
index b1c87e1070..f73e7429b5 100644
--- a/java/org/apache/catalina/mapper/Mapper.java
+++ b/java/org/apache/catalina/mapper/Mapper.java
@@ -1314,7 +1314,8 @@ public final class Mapper {
 private static int compare(CharChunk name, int start, int end, String 
compareTo) {
 int result = 0;
 char[] c = name.getBuffer();
-int len = compareTo.length();
+int compareLen = compareTo.length();
+int len = compareLen;
 if ((end - start) < len) {
 len = end - start;
 }
@@ -1328,9 +1329,9 @@ public final class Mapper {
 }
 }
 if (result == 0) {
-if (len > (end - start)) {
+if (compareLen > (end - start)) {
 result = -1;
-} else if (len < (end - start)) {
+} else if (compareLen < (end - start)) {
 result = 1;
 }
 }
@@ -1345,7 +1346,8 @@ public final class Mapper {
 private static int compareIgnoreCase(CharChunk name, int start, int end, 
String compareTo) {
 int result = 0;
 char[] c = name.getBuffer();
-int len = compareTo.length();
+int compareLen = compareTo.length();
+int len = compareLen;
 if ((end - start) < len) {
 len = end - start;
 }
@@ -1359,9 +1361,9 @@ public final class Mapper {
 }
 }
 if (result == 0) {
-if (len > (end - start)) {
+if (compareLen > (end - start)) {
 result = -1;
-} else if (len < (end - start)) {
+} else if (compareLen < (end - start)) {
 result = 1;
 }
 }


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



[tomcat] branch main updated: Fix a regression in 6353e786

2023-08-10 Thread lihan
This is an automated email from the ASF dual-hosted git repository.

lihan 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 3a92f6a0bf Fix a regression in 6353e786
3a92f6a0bf is described below

commit 3a92f6a0bf3c73451a5fcc0b1d6de6fe5a6bb5b2
Author: lihan 
AuthorDate: Thu Aug 10 15:48:56 2023 +0800

Fix a regression in 6353e786
---
 java/org/apache/catalina/mapper/Mapper.java | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/catalina/mapper/Mapper.java 
b/java/org/apache/catalina/mapper/Mapper.java
index b1cfa8033b..b8708b9c45 100644
--- a/java/org/apache/catalina/mapper/Mapper.java
+++ b/java/org/apache/catalina/mapper/Mapper.java
@@ -1332,7 +1332,8 @@ public final class Mapper {
 private static int compare(CharChunk name, int start, int end, String 
compareTo) {
 int result = 0;
 char[] c = name.getBuffer();
-int len = compareTo.length();
+int compareLen = compareTo.length();
+int len = compareLen;
 if ((end - start) < len) {
 len = end - start;
 }
@@ -1346,9 +1347,9 @@ public final class Mapper {
 }
 }
 if (result == 0) {
-if (len > (end - start)) {
+if (compareLen > (end - start)) {
 result = -1;
-} else if (len < (end - start)) {
+} else if (compareLen < (end - start)) {
 result = 1;
 }
 }
@@ -1363,7 +1364,8 @@ public final class Mapper {
 private static int compareIgnoreCase(CharChunk name, int start, int end, 
String compareTo) {
 int result = 0;
 char[] c = name.getBuffer();
-int len = compareTo.length();
+int compareLen = compareTo.length();
+int len = compareLen;
 if ((end - start) < len) {
 len = end - start;
 }
@@ -1377,9 +1379,9 @@ public final class Mapper {
 }
 }
 if (result == 0) {
-if (len > (end - start)) {
+if (compareLen > (end - start)) {
 result = -1;
-} else if (len < (end - start)) {
+} else if (compareLen < (end - start)) {
 result = 1;
 }
 }


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



Re: [tomcat] branch main updated: Minor optimization

2023-08-10 Thread Han Li


> On Aug 10, 2023, at 15:29, Mark Thomas  wrote:
> 
> On 10/08/2023 04:04, li...@apache.org  wrote:
>> This is an automated email from the ASF dual-hosted git repository.
>> lihan 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 6353e78658 Minor optimization
> 
> -1. Veto. Please fix / revert. Details in-line.
> 
> This veto also applies to the back-ports of this change.
> 
>> 6353e78658 is described below
>> commit 6353e78658ea09c5056943901877f0b6ed31faae
>> Author: lihan 
>> AuthorDate: Wed Aug 9 16:42:11 2023 +0800
>> Minor optimization
>> ---
>> java/org/apache/catalina/mapper/Mapper.java | 20 
>> 1 file changed, 12 insertions(+), 8 deletions(-)
>> diff --git a/java/org/apache/catalina/mapper/Mapper.java 
>> b/java/org/apache/catalina/mapper/Mapper.java
>> index 9a3cfd833f..b1cfa8033b 100644
>> --- a/java/org/apache/catalina/mapper/Mapper.java
>> +++ b/java/org/apache/catalina/mapper/Mapper.java
>> @@ -1337,16 +1337,18 @@ public final class Mapper {
>> len = end - start;
>> }
>> for (int i = 0; (i < len) && (result == 0); i++) {
>> - if (c[i + start] > compareTo.charAt(i)) {
>> + char nameChar = c[i + start];
>> + char compareToChar = compareTo.charAt(i);
>> + if (nameChar > compareToChar) {
>> result = 1;
>> - } else if (c[i + start] < compareTo.charAt(i)) {
>> + } else if (nameChar < compareToChar) {
>> result = -1;
>> }
>> }
>> if (result == 0) {
>> - if (compareTo.length() > (end - start)) {
>> + if (len > (end - start)) {
> 
> compareTo.length() is NOT equivalent to len at this point since len may be 
> modified at the start of the method.

Oops. I'll fix it later.

Han

> 
>> result = -1;
>> - } else if (compareTo.length() < (end - start)) {
>> + } else if (len < (end - start)) {
> 
> Same issue here.
> 
>> result = 1;
>> }
>> }
>> @@ -1366,16 +1368,18 @@ public final class Mapper {
>> len = end - start;
>> }
>> for (int i = 0; (i < len) && (result == 0); i++) {
>> - if (Ascii.toLower(c[i + start]) > Ascii.toLower(compareTo.charAt(i))) {
>> + int nameLower = Ascii.toLower(c[i + start]);
>> + int compareLower = Ascii.toLower(compareTo.charAt(i));
>> + if (nameLower > compareLower) {
>> result = 1;
>> - } else if (Ascii.toLower(c[i + start]) < 
>> Ascii.toLower(compareTo.charAt(i))) {
>> + } else if (nameLower < compareLower) {
>> result = -1;
>> }
>> }
>> if (result == 0) {
>> - if (compareTo.length() > (end - start)) {
>> + if (len > (end - start)) {
> 
> Same issue here.
> 
>> result = -1;
>> - } else if (compareTo.length() < (end - start)) {
>> + } else if (len < (end - start)) {
> 
> Same issue here.
> 
>> result = 1;
>> }
>> }
> 
> Mark
> 
> -
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org 
> 
> For additional commands, e-mail: dev-h...@tomcat.apache.org 
> 


Re: [tomcat] branch main updated: Minor optimization

2023-08-10 Thread Mark Thomas

On 10/08/2023 04:04, li...@apache.org wrote:

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

lihan 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 6353e78658 Minor optimization


-1. Veto. Please fix / revert. Details in-line.

This veto also applies to the back-ports of this change.


6353e78658 is described below

commit 6353e78658ea09c5056943901877f0b6ed31faae
Author: lihan 
AuthorDate: Wed Aug 9 16:42:11 2023 +0800

 Minor optimization
---
  java/org/apache/catalina/mapper/Mapper.java | 20 
  1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/java/org/apache/catalina/mapper/Mapper.java 
b/java/org/apache/catalina/mapper/Mapper.java
index 9a3cfd833f..b1cfa8033b 100644
--- a/java/org/apache/catalina/mapper/Mapper.java
+++ b/java/org/apache/catalina/mapper/Mapper.java
@@ -1337,16 +1337,18 @@ public final class Mapper {
  len = end - start;
  }
  for (int i = 0; (i < len) && (result == 0); i++) {
-if (c[i + start] > compareTo.charAt(i)) {
+char nameChar = c[i + start];
+char compareToChar = compareTo.charAt(i);
+if (nameChar > compareToChar) {
  result = 1;
-} else if (c[i + start] < compareTo.charAt(i)) {
+} else if (nameChar < compareToChar) {
  result = -1;
  }
  }
  if (result == 0) {
-if (compareTo.length() > (end - start)) {
+if (len > (end - start)) {


compareTo.length() is NOT equivalent to len at this point since len may 
be modified at the start of the method.



  result = -1;
-} else if (compareTo.length() < (end - start)) {
+} else if (len < (end - start)) {


Same issue here.


  result = 1;
  }
  }
@@ -1366,16 +1368,18 @@ public final class Mapper {
  len = end - start;
  }
  for (int i = 0; (i < len) && (result == 0); i++) {
-if (Ascii.toLower(c[i + start]) > 
Ascii.toLower(compareTo.charAt(i))) {
+int nameLower = Ascii.toLower(c[i + start]);
+int compareLower = Ascii.toLower(compareTo.charAt(i));
+if (nameLower > compareLower) {
  result = 1;
-} else if (Ascii.toLower(c[i + start]) < 
Ascii.toLower(compareTo.charAt(i))) {
+} else if (nameLower < compareLower) {
  result = -1;
  }
  }
  if (result == 0) {
-if (compareTo.length() > (end - start)) {
+if (len > (end - start)) {


Same issue here.


  result = -1;
-} else if (compareTo.length() < (end - start)) {
+} else if (len < (end - start)) {


Same issue here.


  result = 1;
  }
  }


Mark

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