in common/src/main/java/co/elastic/otel/common/SpanValueStorage.java [87:109]
<V> V computeIfNull(SpanValue<V> key, Supplier<V> valueInitializer) {
int index = key.index;
if (length() > index) {
V currentValue = (V) get(index);
if (currentValue != null) {
return currentValue;
}
compareAndSet(index, null, valueInitializer.get());
return (V) get(index);
} else {
Map<SpanValue<?>, Object> sparseStorage = getSparseValuesMap(true);
V currentValue = (V) sparseStorage.get(key);
if (currentValue != null) {
return currentValue;
}
V newValue = valueInitializer.get();
if (newValue == null) {
return null;
}
sparseStorage.putIfAbsent(key, newValue);
return (V) sparseStorage.get(key);
}
}