You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2023/09/07 13:23:22 UTC

[tomcat] branch 10.1.x updated: Locking cleanup

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 7fd80083ec Locking cleanup
7fd80083ec is described below

commit 7fd80083ec1aa45154c142820c05404490a206de
Author: remm <re...@apache.org>
AuthorDate: Thu Sep 7 15:20:18 2023 +0200

    Locking cleanup
    
    Identified by coverity.
---
 java/org/apache/catalina/realm/MemoryRealm.java | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/java/org/apache/catalina/realm/MemoryRealm.java b/java/org/apache/catalina/realm/MemoryRealm.java
index e918a89eb7..2de6ab75dc 100644
--- a/java/org/apache/catalina/realm/MemoryRealm.java
+++ b/java/org/apache/catalina/realm/MemoryRealm.java
@@ -187,6 +187,7 @@ public class MemoryRealm extends RealmBase {
      *             necessary.
      */
     protected Digester getDigester() {
+        // Keep locking for subclass compatibility
         synchronized (digesterLock) {
             if (digester == null) {
                 digester = new Digester();
@@ -226,16 +227,16 @@ public class MemoryRealm extends RealmBase {
                 log.debug(sm.getString("memoryRealm.loadPath", pathName));
             }
 
-            Digester digester = getDigester();
-            try {
-                synchronized (digester) {
+            synchronized (digesterLock) {
+                Digester digester = getDigester();
+                try {
                     digester.push(this);
                     digester.parse(is);
+                } catch (Exception e) {
+                    throw new LifecycleException(sm.getString("memoryRealm.readXml"), e);
+                } finally {
+                    digester.reset();
                 }
-            } catch (Exception e) {
-                throw new LifecycleException(sm.getString("memoryRealm.readXml"), e);
-            } finally {
-                digester.reset();
             }
         } catch (IOException ioe) {
             throw new LifecycleException(sm.getString("memoryRealm.loadExist", pathName), ioe);


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