AMQ-7423 - Remove synchronization from JAAS PropertiesLoader

This commit is contained in:
Colm O hEigeartaigh 2020-02-27 15:29:26 +00:00
parent cc4a69913b
commit 67fb6f8871
4 changed files with 5 additions and 17 deletions

View File

@ -45,9 +45,8 @@ public class AuthorizationEntry extends DestinationMapEntry {
return groupClass; return groupClass;
} }
@SuppressWarnings("unchecked")
private Set<Object> emptySet() { private Set<Object> emptySet() {
return Collections.EMPTY_SET; return Collections.emptySet();
} }
public void setGroupClass(String groupClass) { public void setGroupClass(String groupClass) {

View File

@ -24,8 +24,6 @@ import java.util.*;
import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.filter.DestinationMap; import org.apache.activemq.filter.DestinationMap;
import org.apache.activemq.filter.DestinationMapEntry; 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 * Represents a destination based configuration of policies so that individual

View File

@ -16,8 +16,6 @@
*/ */
package org.apache.activemq.filter; package org.apache.activemq.filter;
import javax.annotation.PostConstruct;
import org.apache.activemq.command.*; import org.apache.activemq.command.*;
/** /**

View File

@ -17,14 +17,15 @@
package org.apache.activemq.jaas; package org.apache.activemq.jaas;
import java.io.File; import java.io.File;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class PropertiesLoader { public class PropertiesLoader {
private static final Logger LOG = LoggerFactory.getLogger(PropertiesLoader.class); 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; protected boolean debug;
public void init(Map options) { public void init(Map options) {
@ -35,18 +36,10 @@ public class PropertiesLoader {
} }
public ReloadableProperties load(String nameProperty, String fallbackName, Map options) { public ReloadableProperties load(String nameProperty, String fallbackName, Map options) {
ReloadableProperties result;
FileNameKey key = new FileNameKey(nameProperty, fallbackName, options); FileNameKey key = new FileNameKey(nameProperty, fallbackName, options);
key.setDebug(debug); key.setDebug(debug);
synchronized (staticCache) { ReloadableProperties result = staticCache.computeIfAbsent(key, k -> new ReloadableProperties(k));
result = staticCache.get(key);
if (result == null) {
result = new ReloadableProperties(key);
staticCache.put(key, result);
}
}
return result.obtained(); return result.obtained();
} }