(tomcat) branch 9.0.x updated: Fix typo

2024-04-25 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 cb241847f4 Fix typo
cb241847f4 is described below

commit cb241847f4f6bd0e210228f18039afb6cbaee17e
Author: Mark Thomas 
AuthorDate: Thu Apr 25 14:44:43 2024 +0100

Fix typo
---
 test/org/apache/coyote/http11/TestHttp11Processor.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/org/apache/coyote/http11/TestHttp11Processor.java 
b/test/org/apache/coyote/http11/TestHttp11Processor.java
index 55172aef19..a26a7f96a5 100644
--- a/test/org/apache/coyote/http11/TestHttp11Processor.java
+++ b/test/org/apache/coyote/http11/TestHttp11Processor.java
@@ -737,7 +737,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 public void run() {
 if (delayAsyncThread) {
 // Makes the difference between calling complete before
-// the request body is received of after.
+// the request body is received or after.
 try {
 Thread.sleep(1500);
 } catch (InterruptedException 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: Fix typo

2024-04-25 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 4e7335771e Fix typo
4e7335771e is described below

commit 4e7335771e40fa5c2a05f649b2e5938db5b44ae3
Author: Mark Thomas 
AuthorDate: Thu Apr 25 14:44:43 2024 +0100

Fix typo
---
 test/org/apache/coyote/http11/TestHttp11Processor.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/org/apache/coyote/http11/TestHttp11Processor.java 
b/test/org/apache/coyote/http11/TestHttp11Processor.java
index d84ace56bf..65b2015c71 100644
--- a/test/org/apache/coyote/http11/TestHttp11Processor.java
+++ b/test/org/apache/coyote/http11/TestHttp11Processor.java
@@ -737,7 +737,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 public void run() {
 if (delayAsyncThread) {
 // Makes the difference between calling complete before
-// the request body is received of after.
+// the request body is received or after.
 try {
 Thread.sleep(1500);
 } catch (InterruptedException e) {


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



(tomcat) branch main updated: Fix typo

2024-04-25 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 9955b03b6a Fix typo
9955b03b6a is described below

commit 9955b03b6adcfe36ac78b5e1cf416672e346f16a
Author: Mark Thomas 
AuthorDate: Thu Apr 25 14:44:43 2024 +0100

Fix typo
---
 test/org/apache/coyote/http11/TestHttp11Processor.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/org/apache/coyote/http11/TestHttp11Processor.java 
b/test/org/apache/coyote/http11/TestHttp11Processor.java
index dfa05bada4..857d51185d 100644
--- a/test/org/apache/coyote/http11/TestHttp11Processor.java
+++ b/test/org/apache/coyote/http11/TestHttp11Processor.java
@@ -737,7 +737,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 public void run() {
 if (delayAsyncThread) {
 // Makes the difference between calling complete before
-// the request body is received of after.
+// the request body is received or after.
 try {
 Thread.sleep(1500);
 } catch (InterruptedException e) {


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



[Bug 68947] `tomcat-embed-core` `10.1.23` requires Java 11 but includes Java 22 sources

2024-04-25 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=68947

--- Comment #2 from Jack  ---
(In reply to Remy Maucherat from comment #1)
> That's Java 22 actually. Java 11 is supported.

Thanks, amended

> Is there an actual problem or are you asking because of your validation
> rules ?

The latter.

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



Buildbot success in on tomcat-10.1.x

2024-04-25 Thread buildbot
Build status: Build succeeded!
Worker used: bb_worker2_ubuntu
URL: https://ci2.apache.org/#builders/44/builds/1239
Blamelist: remm 
Build Text: build successful
Status Detected: restored build
Build Source Stamp: [branch 10.1.x] 2231a5172fb2565c6c1d55879439d9849d975224


Steps:

  worker_preparation: 0

  git: 0

  shell: 0

  shell_1: 0

  shell_2: 0

  shell_3: 0

  shell_4: 0

  shell_5: 0

  compile: 1

  shell_6: 0

  shell_7: 0

  shell_8: 0

  shell_9: 0

  Rsync docs to nightlies.apache.org: 0

  shell_10: 0

  Rsync RAT to nightlies.apache.org: 0

  compile_1: 1

  shell_11: 0

  Rsync Logs to nightlies.apache.org: 0


-- ASF Buildbot


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



Buildbot success in on tomcat-11.0.x

2024-04-25 Thread buildbot
Build status: Build succeeded!
Worker used: bb_worker2_ubuntu
URL: https://ci2.apache.org/#builders/112/builds/1059
Blamelist: remm 
Build Text: build successful
Status Detected: restored build
Build Source Stamp: [branch main] 07612b5f8ee0034fecaa75359c689a33b203597d


Steps:

  worker_preparation: 0

  git: 0

  shell: 0

  shell_1: 0

  shell_2: 0

  shell_3: 0

  shell_4: 0

  shell_5: 0

  shell_6: 0

  compile: 1

  shell_7: 0

  shell_8: 0

  shell_9: 0

  shell_10: 0

  Rsync docs to nightlies.apache.org: 0

  shell_11: 0

  Rsync RAT to nightlies.apache.org: 0

  compile_1: 1

  shell_12: 0

  Rsync Logs to nightlies.apache.org: 0


-- ASF Buildbot


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



[Bug 68947] `tomcat-embed-core` `10.1.23` requires Java 11 but includes Java 22 sources

2024-04-25 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=68947

Jack  changed:

   What|Removed |Added

Summary|`tomcat-embed-core` |`tomcat-embed-core`
   |`10.1.23` requires Java 11  |`10.1.23` requires Java 11
   |but includes Java 21|but includes Java 22
   |sources |sources

-- 
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 68947] `tomcat-embed-core` `10.1.23` requires Java 11 but includes Java 21 sources

2024-04-25 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=68947

--- Comment #1 from Remy Maucherat  ---
That's Java 22 actually. Java 11 is supported.
Is there an actual problem or are you asking because of your validation rules ?

-- 
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 68947] New: `tomcat-embed-core` `10.1.23` requires Java 11 but includes Java 21 sources

2024-04-25 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=68947

Bug ID: 68947
   Summary: `tomcat-embed-core` `10.1.23` requires Java 11 but
includes Java 21 sources
   Product: Tomcat 10
   Version: 10.1.23
  Hardware: All
OS: All
Status: NEW
  Severity: normal
  Priority: P2
 Component: Packaging
  Assignee: dev@tomcat.apache.org
  Reporter: jackpgr...@gmail.com
  Target Milestone: --

The documentation says Tomcat 10 requires Java 11 -
https://tomcat.apache.org/whichversion.html

The `MANIFEST.mf` of the `tomcat-embed-core-10.1.23.jar` also suggests Java 11:
```
X-Compile-Source-JDK: 11
X-Compile-Target-JDK: 11
```

But some of the included `.class` files have a bytecode level of 66 - i.e. Java
21 - which means they can't be used with Java 11. This was flagged via the
Maven enforcer plugin, using `tomcat-embed-core` as a dependency.

For example - `org/apache/tomcat/util/net/openssl/panama/OpenSSLContext.class`:
`javap -verbose org/apache/tomcat/util/net/openssl/panama/OpenSSLContext.class`
`major version: 66`

This problem doesn't exist (neither does that class) in `10.1.20`.

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



Buildbot failure in on tomcat-10.1.x

2024-04-25 Thread buildbot
Build status: BUILD FAILED: failed compile (failure)
Worker used: bb_worker2_ubuntu
URL: https://ci2.apache.org/#builders/44/builds/1238
Blamelist: remm 
Build Text: failed compile (failure)
Status Detected: new failure
Build Source Stamp: [branch 10.1.x] d9612f98cddbe18a706df2c0ae240eae086ad6ef


Steps:

  worker_preparation: 0

  git: 0

  shell: 0

  shell_1: 0

  shell_2: 0

  shell_3: 0

  shell_4: 0

  shell_5: 0

  compile: 1

  shell_6: 0

  shell_7: 0

  shell_8: 0

  shell_9: 0

  Rsync docs to nightlies.apache.org: 0

  shell_10: 0

  Rsync RAT to nightlies.apache.org: 0

  compile_1: 2

  shell_11: 0

  Rsync Logs to nightlies.apache.org: 0


-- ASF Buildbot


-
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 caught by the testsuite

2024-04-25 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 4d1d5ebea7 Fix NPE caught by the testsuite
4d1d5ebea7 is described below

commit 4d1d5ebea7fe7de7c2b09555e27fd68710ec2ea3
Author: remm 
AuthorDate: Thu Apr 25 13:09:24 2024 +0200

Fix NPE caught by the testsuite
---
 java/org/apache/catalina/servlets/WebdavServlet.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java 
b/java/org/apache/catalina/servlets/WebdavServlet.java
index 4922f2bf6d..d0a3864d82 100644
--- a/java/org/apache/catalina/servlets/WebdavServlet.java
+++ b/java/org/apache/catalina/servlets/WebdavServlet.java
@@ -,9 +,9 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
 List paths = lockNullResources.get(parentPath);
 if (paths != null) {
 paths.remove(path);
-}
-if (paths.isEmpty()) {
-lockNullResources.remove(parentPath);
+if (paths.isEmpty()) {
+lockNullResources.remove(parentPath);
+}
 }
 }
 }


-
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 caught by the testsuite

2024-04-25 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 2231a5172f Fix NPE caught by the testsuite
2231a5172f is described below

commit 2231a5172fb2565c6c1d55879439d9849d975224
Author: remm 
AuthorDate: Thu Apr 25 13:09:24 2024 +0200

Fix NPE caught by the testsuite
---
 java/org/apache/catalina/servlets/WebdavServlet.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java 
b/java/org/apache/catalina/servlets/WebdavServlet.java
index 7afe45a378..f1401c56cd 100644
--- a/java/org/apache/catalina/servlets/WebdavServlet.java
+++ b/java/org/apache/catalina/servlets/WebdavServlet.java
@@ -2223,9 +2223,9 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
 List paths = lockNullResources.get(parentPath);
 if (paths != null) {
 paths.remove(path);
-}
-if (paths.isEmpty()) {
-lockNullResources.remove(parentPath);
+if (paths.isEmpty()) {
+lockNullResources.remove(parentPath);
+}
 }
 }
 }


-
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 caught by the testsuite

2024-04-25 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 07612b5f8e Fix NPE caught by the testsuite
07612b5f8e is described below

commit 07612b5f8ee0034fecaa75359c689a33b203597d
Author: remm 
AuthorDate: Thu Apr 25 13:09:24 2024 +0200

Fix NPE caught by the testsuite
---
 java/org/apache/catalina/servlets/WebdavServlet.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java 
b/java/org/apache/catalina/servlets/WebdavServlet.java
index 7afe45a378..f1401c56cd 100644
--- a/java/org/apache/catalina/servlets/WebdavServlet.java
+++ b/java/org/apache/catalina/servlets/WebdavServlet.java
@@ -2223,9 +2223,9 @@ public class WebdavServlet extends DefaultServlet 
implements PeriodicEventListen
 List paths = lockNullResources.get(parentPath);
 if (paths != null) {
 paths.remove(path);
-}
-if (paths.isEmpty()) {
-lockNullResources.remove(parentPath);
+if (paths.isEmpty()) {
+lockNullResources.remove(parentPath);
+}
 }
 }
 }


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



Buildbot failure in on tomcat-11.0.x

2024-04-25 Thread buildbot
Build status: BUILD FAILED: failed compile (failure)
Worker used: bb_worker2_ubuntu
URL: https://ci2.apache.org/#builders/112/builds/1058
Blamelist: remm 
Build Text: failed compile (failure)
Status Detected: new failure
Build Source Stamp: [branch main] 01215beaccfbd8139a62074ad7e58abe5e34e85b


Steps:

  worker_preparation: 0

  git: 0

  shell: 0

  shell_1: 0

  shell_2: 0

  shell_3: 0

  shell_4: 0

  shell_5: 0

  shell_6: 0

  compile: 1

  shell_7: 0

  shell_8: 0

  shell_9: 0

  shell_10: 0

  Rsync docs to nightlies.apache.org: 0

  shell_11: 0

  Rsync RAT to nightlies.apache.org: 0

  compile_1: 2

  shell_12: 0

  Rsync Logs to nightlies.apache.org: 0


-- ASF Buildbot


-
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: Improve locks handling

2024-04-25 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 eeb52a0e3f Improve locks handling
eeb52a0e3f is described below

commit eeb52a0e3f5c102b08e4669b55b9cab9c32fe563
Author: remm 
AuthorDate: Thu Apr 25 12:11:52 2024 +0200

Improve locks handling

Fix WebDAV lock null (locks for non existing resources) thread safety
and removal.
Add periodic checking for WebDAV locks expiration.
---
 .../apache/catalina/servlets/WebdavServlet.java| 53 ++
 webapps/docs/changelog.xml |  7 +++
 2 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java 
b/java/org/apache/catalina/servlets/WebdavServlet.java
index fb543280fb..4922f2bf6d 100644
--- a/java/org/apache/catalina/servlets/WebdavServlet.java
+++ b/java/org/apache/catalina/servlets/WebdavServlet.java
@@ -37,6 +37,7 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.TimeZone;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 import javax.servlet.DispatcherType;
 import javax.servlet.RequestDispatcher;
@@ -52,6 +53,7 @@ import org.apache.catalina.WebResource;
 import org.apache.catalina.connector.RequestFacade;
 import org.apache.catalina.util.DOMWriter;
 import org.apache.catalina.util.XMLWriter;
+import org.apache.tomcat.PeriodicEventListener;
 import org.apache.tomcat.util.buf.HexUtils;
 import org.apache.tomcat.util.http.ConcurrentDateFormat;
 import org.apache.tomcat.util.http.FastHttpDateFormat;
@@ -128,11 +130,9 @@ import org.xml.sax.SAXException;
  * access will be able to edit content available via 
http://host:port/context/content using
  * http://host:port/context/webdavedit/content
  *
- * @author Remy Maucherat
- *
  * @see https://tools.ietf.org/html/rfc4918;>RFC 4918
  */
-public class WebdavServlet extends DefaultServlet {
+public class WebdavServlet extends DefaultServlet implements 
PeriodicEventListener {
 
 private static final long serialVersionUID = 1L;
 
@@ -272,6 +272,26 @@ public class WebdavServlet extends DefaultServlet {
 }
 
 
+@Override
+public void periodicEvent() {
+// Check expiration of all locks
+for (LockInfo currentLock : resourceLocks.values()) {
+if (currentLock.hasExpired()) {
+resourceLocks.remove(currentLock.path);
+removeLockNull(currentLock.path);
+}
+}
+Iterator collectionLocksIterator = 
collectionLocks.iterator();
+while (collectionLocksIterator.hasNext()) {
+LockInfo currentLock = collectionLocksIterator.next();
+if (currentLock.hasExpired()) {
+collectionLocksIterator.remove();
+removeLockNull(currentLock.path);
+}
+}
+}
+
+
 // -- Protected Methods
 
 /**
@@ -726,7 +746,7 @@ public class WebdavServlet extends DefaultServlet {
 if (resources.mkdir(path)) {
 resp.setStatus(WebdavStatus.SC_CREATED);
 // Removing any lock-null resource which would be present
-lockNullResources.remove(path);
+removeLockNull(path);
 } else {
 resp.sendError(WebdavStatus.SC_CONFLICT);
 }
@@ -786,7 +806,7 @@ public class WebdavServlet extends DefaultServlet {
 super.doPut(req, resp);
 
 // Removing any lock-null resource which would be present
-lockNullResources.remove(path);
+removeLockNull(path);
 }
 
 
@@ -1176,7 +1196,7 @@ public class WebdavServlet extends DefaultServlet {
 int slash = lock.path.lastIndexOf('/');
 String parentPath = lock.path.substring(0, slash);
 
-lockNullResources.computeIfAbsent(parentPath, k -> new 
ArrayList<>()).add(lock.path);
+lockNullResources.computeIfAbsent(parentPath, k -> new 
CopyOnWriteArrayList<>()).add(lock.path);
 }
 
 // Add the Lock-Token header as by RFC 2518 8.10.1
@@ -1286,7 +1306,7 @@ public class WebdavServlet extends DefaultServlet {
 if (lock.tokens.isEmpty()) {
 resourceLocks.remove(path);
 // Removing any lock-null resource which would be present
-lockNullResources.remove(path);
+removeLockNull(path);
 }
 
 }
@@ -1307,7 +1327,7 @@ public class WebdavServlet extends DefaultServlet {
 if (lock.tokens.isEmpty()) {
 collectionLocksList.remove();
 // Removing any lock-null resource which would be present
-lockNullResources.remove(path);
+   

(tomcat) branch 10.1.x updated: Improve locks handling

2024-04-25 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 d9612f98cd Improve locks handling
d9612f98cd is described below

commit d9612f98cddbe18a706df2c0ae240eae086ad6ef
Author: remm 
AuthorDate: Thu Apr 25 12:11:52 2024 +0200

Improve locks handling

Fix WebDAV lock null (locks for non existing resources) thread safety
and removal.
Add periodic checking for WebDAV locks expiration.
---
 .../apache/catalina/servlets/WebdavServlet.java| 53 ++
 webapps/docs/changelog.xml |  7 +++
 2 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java 
b/java/org/apache/catalina/servlets/WebdavServlet.java
index 1f1aae190b..7afe45a378 100644
--- a/java/org/apache/catalina/servlets/WebdavServlet.java
+++ b/java/org/apache/catalina/servlets/WebdavServlet.java
@@ -37,6 +37,7 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.TimeZone;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -53,6 +54,7 @@ import org.apache.catalina.WebResource;
 import org.apache.catalina.connector.RequestFacade;
 import org.apache.catalina.util.DOMWriter;
 import org.apache.catalina.util.XMLWriter;
+import org.apache.tomcat.PeriodicEventListener;
 import org.apache.tomcat.util.buf.HexUtils;
 import org.apache.tomcat.util.http.ConcurrentDateFormat;
 import org.apache.tomcat.util.http.FastHttpDateFormat;
@@ -129,11 +131,9 @@ import org.xml.sax.SAXException;
  * access will be able to edit content available via 
http://host:port/context/content using
  * http://host:port/context/webdavedit/content
  *
- * @author Remy Maucherat
- *
  * @see https://tools.ietf.org/html/rfc4918;>RFC 4918
  */
-public class WebdavServlet extends DefaultServlet {
+public class WebdavServlet extends DefaultServlet implements 
PeriodicEventListener {
 
 private static final long serialVersionUID = 1L;
 
@@ -273,6 +273,26 @@ public class WebdavServlet extends DefaultServlet {
 }
 
 
+@Override
+public void periodicEvent() {
+// Check expiration of all locks
+for (LockInfo currentLock : resourceLocks.values()) {
+if (currentLock.hasExpired()) {
+resourceLocks.remove(currentLock.path);
+removeLockNull(currentLock.path);
+}
+}
+Iterator collectionLocksIterator = 
collectionLocks.iterator();
+while (collectionLocksIterator.hasNext()) {
+LockInfo currentLock = collectionLocksIterator.next();
+if (currentLock.hasExpired()) {
+collectionLocksIterator.remove();
+removeLockNull(currentLock.path);
+}
+}
+}
+
+
 // -- Protected Methods
 
 /**
@@ -727,7 +747,7 @@ public class WebdavServlet extends DefaultServlet {
 if (resources.mkdir(path)) {
 resp.setStatus(WebdavStatus.SC_CREATED);
 // Removing any lock-null resource which would be present
-lockNullResources.remove(path);
+removeLockNull(path);
 } else {
 resp.sendError(WebdavStatus.SC_CONFLICT);
 }
@@ -787,7 +807,7 @@ public class WebdavServlet extends DefaultServlet {
 super.doPut(req, resp);
 
 // Removing any lock-null resource which would be present
-lockNullResources.remove(path);
+removeLockNull(path);
 }
 
 
@@ -1177,7 +1197,7 @@ public class WebdavServlet extends DefaultServlet {
 int slash = lock.path.lastIndexOf('/');
 String parentPath = lock.path.substring(0, slash);
 
-lockNullResources.computeIfAbsent(parentPath, k -> new 
ArrayList<>()).add(lock.path);
+lockNullResources.computeIfAbsent(parentPath, k -> new 
CopyOnWriteArrayList<>()).add(lock.path);
 }
 
 // Add the Lock-Token header as by RFC 2518 8.10.1
@@ -1287,7 +1307,7 @@ public class WebdavServlet extends DefaultServlet {
 if (lock.tokens.isEmpty()) {
 resourceLocks.remove(path);
 // Removing any lock-null resource which would be present
-lockNullResources.remove(path);
+removeLockNull(path);
 }
 
 }
@@ -1308,7 +1328,7 @@ public class WebdavServlet extends DefaultServlet {
 if (lock.tokens.isEmpty()) {
 collectionLocksList.remove();
 // Removing any lock-null resource which would be present
-

(tomcat) branch main updated: Improve locks handling

2024-04-25 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 01215beacc Improve locks handling
01215beacc is described below

commit 01215beaccfbd8139a62074ad7e58abe5e34e85b
Author: remm 
AuthorDate: Thu Apr 25 12:11:52 2024 +0200

Improve locks handling

Fix WebDAV lock null (locks for non existing resources) thread safety
and removal.
Add periodic checking for WebDAV locks expiration.
---
 .../apache/catalina/servlets/WebdavServlet.java| 53 ++
 webapps/docs/changelog.xml |  7 +++
 2 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java 
b/java/org/apache/catalina/servlets/WebdavServlet.java
index 1f1aae190b..7afe45a378 100644
--- a/java/org/apache/catalina/servlets/WebdavServlet.java
+++ b/java/org/apache/catalina/servlets/WebdavServlet.java
@@ -37,6 +37,7 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.TimeZone;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -53,6 +54,7 @@ import org.apache.catalina.WebResource;
 import org.apache.catalina.connector.RequestFacade;
 import org.apache.catalina.util.DOMWriter;
 import org.apache.catalina.util.XMLWriter;
+import org.apache.tomcat.PeriodicEventListener;
 import org.apache.tomcat.util.buf.HexUtils;
 import org.apache.tomcat.util.http.ConcurrentDateFormat;
 import org.apache.tomcat.util.http.FastHttpDateFormat;
@@ -129,11 +131,9 @@ import org.xml.sax.SAXException;
  * access will be able to edit content available via 
http://host:port/context/content using
  * http://host:port/context/webdavedit/content
  *
- * @author Remy Maucherat
- *
  * @see https://tools.ietf.org/html/rfc4918;>RFC 4918
  */
-public class WebdavServlet extends DefaultServlet {
+public class WebdavServlet extends DefaultServlet implements 
PeriodicEventListener {
 
 private static final long serialVersionUID = 1L;
 
@@ -273,6 +273,26 @@ public class WebdavServlet extends DefaultServlet {
 }
 
 
+@Override
+public void periodicEvent() {
+// Check expiration of all locks
+for (LockInfo currentLock : resourceLocks.values()) {
+if (currentLock.hasExpired()) {
+resourceLocks.remove(currentLock.path);
+removeLockNull(currentLock.path);
+}
+}
+Iterator collectionLocksIterator = 
collectionLocks.iterator();
+while (collectionLocksIterator.hasNext()) {
+LockInfo currentLock = collectionLocksIterator.next();
+if (currentLock.hasExpired()) {
+collectionLocksIterator.remove();
+removeLockNull(currentLock.path);
+}
+}
+}
+
+
 // -- Protected Methods
 
 /**
@@ -727,7 +747,7 @@ public class WebdavServlet extends DefaultServlet {
 if (resources.mkdir(path)) {
 resp.setStatus(WebdavStatus.SC_CREATED);
 // Removing any lock-null resource which would be present
-lockNullResources.remove(path);
+removeLockNull(path);
 } else {
 resp.sendError(WebdavStatus.SC_CONFLICT);
 }
@@ -787,7 +807,7 @@ public class WebdavServlet extends DefaultServlet {
 super.doPut(req, resp);
 
 // Removing any lock-null resource which would be present
-lockNullResources.remove(path);
+removeLockNull(path);
 }
 
 
@@ -1177,7 +1197,7 @@ public class WebdavServlet extends DefaultServlet {
 int slash = lock.path.lastIndexOf('/');
 String parentPath = lock.path.substring(0, slash);
 
-lockNullResources.computeIfAbsent(parentPath, k -> new 
ArrayList<>()).add(lock.path);
+lockNullResources.computeIfAbsent(parentPath, k -> new 
CopyOnWriteArrayList<>()).add(lock.path);
 }
 
 // Add the Lock-Token header as by RFC 2518 8.10.1
@@ -1287,7 +1307,7 @@ public class WebdavServlet extends DefaultServlet {
 if (lock.tokens.isEmpty()) {
 resourceLocks.remove(path);
 // Removing any lock-null resource which would be present
-lockNullResources.remove(path);
+removeLockNull(path);
 }
 
 }
@@ -1308,7 +1328,7 @@ public class WebdavServlet extends DefaultServlet {
 if (lock.tokens.isEmpty()) {
 collectionLocksList.remove();
 // Removing any lock-null resource which would be present
-lockNullResources.remove(path);