Skip to content

Commit 008cf95

Browse files
authored
Switch to ConcurrentMap for thread-safety (#328)
1 parent 396b54e commit 008cf95

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

detectors/resources-support/src/main/java/com/google/cloud/opentelemetry/detection/GCPMetadataConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import java.net.HttpURLConnection;
2323
import java.net.URL;
2424
import java.nio.charset.StandardCharsets;
25-
import java.util.HashMap;
2625
import java.util.Map;
26+
import java.util.concurrent.ConcurrentHashMap;
2727

2828
/**
2929
* Retrieves Google Cloud project-id and a limited set of instance attributes from Metadata server.
@@ -36,7 +36,7 @@ final class GCPMetadataConfig {
3636

3737
private static final String DEFAULT_URL = "http://metadata.google.internal/computeMetadata/v1/";
3838
private final String url;
39-
private final Map<String, String> cachedAttributes = new HashMap<>();
39+
private final Map<String, String> cachedAttributes = new ConcurrentHashMap<>();
4040

4141
private GCPMetadataConfig() {
4242
this.url = DEFAULT_URL;

0 commit comments

Comments
 (0)