DATAKV-297 - Use computeIfAbsent to create keyspace maps.
We now use computeIfAbsent to ensure atomic creation of keyspace maps if the underlying Map implementation allows for concurrent access.
This commit is contained in:
@@ -189,17 +189,7 @@ public class MapKeyValueAdapter extends AbstractKeyValueAdapter {
|
||||
|
||||
Assert.notNull(keyspace, "Collection must not be null for lookup.");
|
||||
|
||||
Map<Object, Object> map = store.get(keyspace);
|
||||
|
||||
if (map != null) {
|
||||
return map;
|
||||
}
|
||||
|
||||
addMapForKeySpace(keyspace);
|
||||
return store.get(keyspace);
|
||||
return store.computeIfAbsent(keyspace, it -> CollectionFactory.createMap(keySpaceMapType, 1000));
|
||||
}
|
||||
|
||||
private void addMapForKeySpace(String keyspace) {
|
||||
store.put(keyspace, CollectionFactory.createMap(keySpaceMapType, 1000));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user