Skip to content

Commit

Permalink
reverted to inline initialization
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Wert <alexander.wert@elastic.co>
  • Loading branch information
AlexanderWert committed Nov 14, 2023
1 parent fa5b74d commit e121d5d
Showing 1 changed file with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public final class AttributeKeyTemplate<T> {

private final String prefix;
private final Function<String, AttributeKey<T>> keyBuilder;
private ConcurrentMap<String, AttributeKey<T>> keysCache;
private final ConcurrentMap<String, AttributeKey<T>> keysCache = new ConcurrentHashMap<>(1);;

AttributeKeyTemplate(String prefix, Function<String, AttributeKey<T>> keyBuilder) {
this.prefix = prefix;
Expand Down Expand Up @@ -73,9 +73,6 @@ private AttributeKey<T> createAttributeKey(String keyName) {
* @return An {@link AttributeKey} object for the given key.
*/
public AttributeKey<T> getAttributeKey(String key) {
if (keysCache == null) {
keysCache = new ConcurrentHashMap<>(1);
}
return keysCache.computeIfAbsent(key, this::createAttributeKey);
}
}

0 comments on commit e121d5d

Please sign in to comment.