From e121d5db0b72a53f95d83bf6e3614abfd241c104 Mon Sep 17 00:00:00 2001 From: Alexander Wert Date: Tue, 14 Nov 2023 07:35:50 +0100 Subject: [PATCH] reverted to inline initialization Signed-off-by: Alexander Wert --- .../java/io/opentelemetry/semconv/AttributeKeyTemplate.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/io/opentelemetry/semconv/AttributeKeyTemplate.java b/src/main/java/io/opentelemetry/semconv/AttributeKeyTemplate.java index 9408b7c..efa6e54 100644 --- a/src/main/java/io/opentelemetry/semconv/AttributeKeyTemplate.java +++ b/src/main/java/io/opentelemetry/semconv/AttributeKeyTemplate.java @@ -16,7 +16,7 @@ public final class AttributeKeyTemplate { private final String prefix; private final Function> keyBuilder; - private ConcurrentMap> keysCache; + private final ConcurrentMap> keysCache = new ConcurrentHashMap<>(1);; AttributeKeyTemplate(String prefix, Function> keyBuilder) { this.prefix = prefix; @@ -73,9 +73,6 @@ private AttributeKey createAttributeKey(String keyName) { * @return An {@link AttributeKey} object for the given key. */ public AttributeKey getAttributeKey(String key) { - if (keysCache == null) { - keysCache = new ConcurrentHashMap<>(1); - } return keysCache.computeIfAbsent(key, this::createAttributeKey); } }