This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new 72a46ed4c1 Fix locking - found by SpotBugs
72a46ed4c1 is described below
commit 72a46ed4c1471fcdf09d0946af7ffa381f320060
Author: Mark Thomas <[email protected]>
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 1e6593f3f4..fa7f9a83d2 100644
--- a/java/org/apache/catalina/realm/MemoryRealm.java
+++ b/java/org/apache/catalina/realm/MemoryRealm.java
@@ -53,6 +53,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();
/**
@@ -194,18 +195,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: [email protected]
For additional commands, e-mail: [email protected]