On Wed, Jun 10, 2026 at 12:30 PM <[email protected]> wrote:
>
> This is an automated email from the ASF dual-hosted git repository.
>
> markt-asf 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 79cc563af5 Fix potential deadlock on copy
> 79cc563af5 is described below
>
> commit 79cc563af5e4b0580c2213dfda58675105a79d55
> Author: Mark Thomas <[email protected]>
> AuthorDate: Wed Jun 10 11:29:02 2026 +0100
>
>     Fix potential deadlock on copy

I paused my minor fixes work from code review since you asked, but
when is the next tag going to be so that I can resume ? The longer we
wait, the more likely we get flooded by 1000s of PRs about the same
minor stuff (I fear we'll get flooded anyway ...).

Rémy

> ---
>  java/org/apache/catalina/servlets/WebdavServlet.java | 18 ++++++++++++++++--
>  webapps/docs/changelog.xml                           |  3 +++
>  2 files changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java 
> b/java/org/apache/catalina/servlets/WebdavServlet.java
> index 7eb089f935..81e0fbc52e 100644
> --- a/java/org/apache/catalina/servlets/WebdavServlet.java
> +++ b/java/org/apache/catalina/servlets/WebdavServlet.java
> @@ -2983,8 +2983,22 @@ public class WebdavServlet extends DefaultServlet 
> implements PeriodicEventListen
>                      propertiesDest = new ArrayList<>();
>                      deadProperties.put(destination, propertiesDest);
>                  }
> -                synchronized (properties) {
> -                    synchronized (propertiesDest) {
> +                /*
> +                 * The following ensures that locks for any two paths are 
> always obtained in the same other order
> +                 * regardless of which is the source and which is the 
> destination. This is to avoid deadlocks for
> +                 * concurrent calls where source and destination are 
> reversed.
> +                 */
> +                Object lockFirst;
> +                Object lockSecond;
> +                if (source.compareTo(destination) > 0) {
> +                    lockFirst = properties;
> +                    lockSecond = propertiesDest;
> +                } else {
> +                    lockFirst = propertiesDest;
> +                    lockSecond = properties;
> +                }
> +                synchronized (lockFirst) {
> +                    synchronized (lockSecond) {
>                          for (Node node : properties) {
>                              node = node.cloneNode(true);
>                              boolean found = false;
> diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
> index c084a0f64e..b49aaf5d55 100644
> --- a/webapps/docs/changelog.xml
> +++ b/webapps/docs/changelog.xml
> @@ -375,6 +375,9 @@
>          <code>server.xml</code>. Cluster digester rules are now fully
>          conditional on both JARs being available. (dsoumis)
>        </fix>
> +      <fix>
> +        Fix a potential deadlock when copying resources using WebDAV. (markt)
> +      </fix>
>      </changelog>
>    </subsection>
>    <subsection name="Coyote">
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to