This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.0.x by this push: new 9247e52999 Fix locking - found by SpotBugs 9247e52999 is described below commit 9247e52999f49a494b984db06dff4636bde6736c Author: Mark Thomas <ma...@apache.org> AuthorDate: Mon Sep 12 10:00:40 2022 +0100 Fix locking - found by SpotBugs --- java/org/apache/catalina/realm/MemoryRealm.java | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/java/org/apache/catalina/realm/MemoryRealm.java b/java/org/apache/catalina/realm/MemoryRealm.java index 7c1671e621..2584438291 100644 --- a/java/org/apache/catalina/realm/MemoryRealm.java +++ b/java/org/apache/catalina/realm/MemoryRealm.java @@ -54,6 +54,7 @@ public class MemoryRealm extends RealmBase { * The Digester we will use to process in-memory database files. */ private static Digester digester = null; + private static final Object digesterLock = new Object(); /** @@ -197,18 +198,18 @@ public class MemoryRealm extends RealmBase { * @return a configured <code>Digester</code> to use for processing * the XML input file, creating a new one if necessary. */ - protected synchronized Digester getDigester() { - if (digester == null) { - digester = new Digester(); - digester.setValidating(false); - try { - digester.setFeature( - "http://apache.org/xml/features/allow-java-encodings", - true); - } catch (Exception e) { - log.warn(sm.getString("memoryRealm.xmlFeatureEncoding"), e); + protected Digester getDigester() { + synchronized (digesterLock) { + if (digester == null) { + digester = new Digester(); + digester.setValidating(false); + try { + digester.setFeature("http://apache.org/xml/features/allow-java-encodings", true); + } catch (Exception e) { + log.warn(sm.getString("memoryRealm.xmlFeatureEncoding"), e); + } + digester.addRuleSet(new MemoryRuleSet()); } - digester.addRuleSet(new MemoryRuleSet()); } return digester; } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org