Skip to content

Commit df23b29

Browse files
fix(spanner): cache auto-tagging options to avoid system property lock contention
1 parent b2bc2d4 commit df23b29

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

java-spanner/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,11 @@ protected SpannerOptions(Builder builder) {
997997
monitoringHost = builder.monitoringHost;
998998
defaultTransactionOptions = builder.defaultTransactionOptions;
999999
clientContext = builder.clientContext;
1000-
autoTaggingEnabled = builder.autoTaggingEnabled;
1000+
if (environment.isAutoTaggingDisabled()) {
1001+
autoTaggingEnabled = false;
1002+
} else {
1003+
autoTaggingEnabled = builder.autoTaggingEnabled || environment.isAutoTaggingEnabled();
1004+
}
10011005
autoTaggingPackages = builder.autoTaggingPackages;
10021006
autoTaggingTracerLimit = builder.autoTaggingTracerLimit;
10031007
}
@@ -2611,10 +2615,7 @@ public TransactionOptions getDefaultTransactionOptions() {
26112615
}
26122616

26132617
public boolean isAutoTaggingEnabled() {
2614-
if (environment.isAutoTaggingDisabled()) {
2615-
return false;
2616-
}
2617-
return autoTaggingEnabled || environment.isAutoTaggingEnabled();
2618+
return autoTaggingEnabled;
26182619
}
26192620

26202621
public List<String> getAutoTaggingPackages() {
@@ -2625,10 +2626,6 @@ public int getAutoTaggingTracerLimit() {
26252626
return autoTaggingTracerLimit;
26262627
}
26272628

2628-
public boolean isAutoTaggingDisabled() {
2629-
return environment.isAutoTaggingDisabled();
2630-
}
2631-
26322629
@BetaApi
26332630
public boolean isUseVirtualThreads() {
26342631
return useVirtualThreads;

0 commit comments

Comments
 (0)