Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public class ConfigDepotImpl implements ConfigDepot, ConfigDepotAdmin {
List<ScopedConfigStorage> _scopedStorages;
Set<Configurable> _configured = Collections.synchronizedSet(new HashSet<Configurable>());
Set<String> newConfigs = Collections.synchronizedSet(new HashSet<>());
LazyCache<String, String> configCache;
LazyCache<Ternary<String, ConfigKey.Scope, Long>, String> configCache;

private HashMap<String, Pair<String, ConfigKey<?>>> _allKeys = new HashMap<String, Pair<String, ConfigKey<?>>>(1007);

Expand Down Expand Up @@ -273,15 +273,10 @@ public ConfigurationDao global() {
return _configDao;
}

protected String getConfigStringValueInternal(String cacheKey) {
String[] parts = cacheKey.split("-");
String key = parts[0];
ConfigKey.Scope scope = ConfigKey.Scope.Global;
Long scopeId = null;
try {
scope = ConfigKey.Scope.valueOf(parts[1]);
scopeId = Long.valueOf(parts[2]);
} catch (IllegalArgumentException ignored) {}
protected String getConfigStringValueInternal(Ternary<String, ConfigKey.Scope, Long> cacheKey) {
String key = cacheKey.first();
ConfigKey.Scope scope = cacheKey.second();
Long scopeId = cacheKey.third();
if (!ConfigKey.Scope.Global.equals(scope) && scopeId != null) {
ScopedConfigStorage scopedConfigStorage = null;
for (ScopedConfigStorage storage : _scopedStorages) {
Expand All @@ -301,8 +296,8 @@ protected String getConfigStringValueInternal(String cacheKey) {
return null;
}

private String getConfigCacheKey(String key, ConfigKey.Scope scope, Long scopeId) {
return String.format("%s-%s-%d", key, scope, (scopeId == null ? 0 : scopeId));
protected Ternary<String, ConfigKey.Scope, Long> getConfigCacheKey(String key, ConfigKey.Scope scope, Long scopeId) {
return new Ternary<>(key, scope, scopeId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ public void testGetConfigStringValue() {
runTestGetConfigStringValue("test", "value");
}

@Test
public void testGetConfigStringValue_nameWithCharacters() {
runTestGetConfigStringValue("test.1-1", "value");
runTestGetConfigStringValue("test_1#2", "value");
}

private void runTestGetConfigStringValueExpiry(long wait, int configDBRetrieval) {
String key = "test1";
String value = "expiry";
Expand Down