activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject [activemq] branch activemq-5.15.x updated: AMQ-7423 - Remove synchronization from JAAS PropertiesLoader
Date Fri, 28 Feb 2020 06:31:45 GMT
This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch activemq-5.15.x
in repository https://gitbox.apache.org/repos/asf/activemq.git


The following commit(s) were added to refs/heads/activemq-5.15.x by this push:
     new ae9d1c5  AMQ-7423 - Remove synchronization from JAAS PropertiesLoader
ae9d1c5 is described below

commit ae9d1c5136e0ade3209772348ef69b263be7ed05
Author: Colm O hEigeartaigh <coheigea@apache.org>
AuthorDate: Thu Feb 27 15:29:26 2020 +0000

    AMQ-7423 - Remove synchronization from JAAS PropertiesLoader
    
    (cherry picked from commit 67fb6f8871a04e18870fda65ac5eab9d486da309)
---
 .../org/apache/activemq/security/AuthorizationEntry.java  |  3 +--
 .../apache/activemq/security/DefaultAuthorizationMap.java |  2 --
 .../org/apache/activemq/filter/DestinationMapEntry.java   |  2 --
 .../java/org/apache/activemq/jaas/PropertiesLoader.java   | 15 ++++-----------
 4 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/activemq-broker/src/main/java/org/apache/activemq/security/AuthorizationEntry.java
b/activemq-broker/src/main/java/org/apache/activemq/security/AuthorizationEntry.java
index 37f07ba..8d208ff 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/security/AuthorizationEntry.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/security/AuthorizationEntry.java
@@ -45,9 +45,8 @@ public class AuthorizationEntry extends DestinationMapEntry {
         return groupClass;
     }
 
-    @SuppressWarnings("unchecked")
     private Set<Object> emptySet() {
-        return Collections.EMPTY_SET;
+        return Collections.emptySet();
     }
 
     public void setGroupClass(String groupClass) {
diff --git a/activemq-broker/src/main/java/org/apache/activemq/security/DefaultAuthorizationMap.java
b/activemq-broker/src/main/java/org/apache/activemq/security/DefaultAuthorizationMap.java
index b249119..e27f8a7 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/security/DefaultAuthorizationMap.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/security/DefaultAuthorizationMap.java
@@ -24,8 +24,6 @@ import java.util.*;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.filter.DestinationMap;
 import org.apache.activemq.filter.DestinationMapEntry;
-import org.apache.activemq.filter.DestinationMapNode;
-import org.apache.activemq.filter.DestinationNode;
 
 /**
  * Represents a destination based configuration of policies so that individual
diff --git a/activemq-client/src/main/java/org/apache/activemq/filter/DestinationMapEntry.java
b/activemq-client/src/main/java/org/apache/activemq/filter/DestinationMapEntry.java
index f1d7838..c08ebca 100644
--- a/activemq-client/src/main/java/org/apache/activemq/filter/DestinationMapEntry.java
+++ b/activemq-client/src/main/java/org/apache/activemq/filter/DestinationMapEntry.java
@@ -16,8 +16,6 @@
  */
 package org.apache.activemq.filter;
 
-import javax.annotation.PostConstruct;
-
 import org.apache.activemq.command.*;
 
 /**
diff --git a/activemq-jaas/src/main/java/org/apache/activemq/jaas/PropertiesLoader.java b/activemq-jaas/src/main/java/org/apache/activemq/jaas/PropertiesLoader.java
index 3f2df61..0ed8376 100644
--- a/activemq-jaas/src/main/java/org/apache/activemq/jaas/PropertiesLoader.java
+++ b/activemq-jaas/src/main/java/org/apache/activemq/jaas/PropertiesLoader.java
@@ -17,14 +17,15 @@
 package org.apache.activemq.jaas;
 
 import java.io.File;
-import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class PropertiesLoader {
     private static final Logger LOG = LoggerFactory.getLogger(PropertiesLoader.class);
-    static final Map<FileNameKey, ReloadableProperties> staticCache = new HashMap<FileNameKey,
ReloadableProperties>();
+    private static final Map<FileNameKey, ReloadableProperties> staticCache = new ConcurrentHashMap<FileNameKey,
ReloadableProperties>();
     protected boolean debug;
 
     public void init(Map options) {
@@ -35,18 +36,10 @@ public class PropertiesLoader {
     }
 
     public ReloadableProperties load(String nameProperty, String fallbackName, Map options)
{
-        ReloadableProperties result;
         FileNameKey key = new FileNameKey(nameProperty, fallbackName, options);
         key.setDebug(debug);
 
-        synchronized (staticCache) {
-            result = staticCache.get(key);
-            if (result == null) {
-                result = new ReloadableProperties(key);
-                staticCache.put(key, result);
-            }
-        }
-
+        ReloadableProperties result = staticCache.computeIfAbsent(key, k -> new ReloadableProperties(k));
         return result.obtained();
     }
 


Mime
View raw message