mirror of https://github.com/apache/activemq.git
Merge pull request #479 from coheigea/AMQ-7423
AMQ-7423 - Remove synchronization from JAAS PropertiesLoader
This commit is contained in:
commit
51081e4edf
|
@ -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) {
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue