Merge pull request #479 from coheigea/AMQ-7423

AMQ-7423 - Remove synchronization from JAAS PropertiesLoader
This commit is contained in:
Jean-Baptiste Onofré 2020-02-28 07:30:57 +01:00 committed by GitHub
commit 51081e4edf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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();
} }