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

commit 5f76adcf6661caece403a05cddc4c638c1425666
Author: remm <r...@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 9f12cd4055..70a437df42 100644
--- a/java/org/apache/catalina/realm/MemoryRealm.java
+++ b/java/org/apache/catalina/realm/MemoryRealm.java
@@ -176,6 +176,7 @@ public class MemoryRealm extends RealmBase {
      *             necessary.
      */
     protected Digester getDigester() {
+        // Keep locking for subclass compatibility
         synchronized (digesterLock) {
             if (digester == null) {
                 digester = new Digester();
@@ -222,16 +223,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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to