Repository navigation
fix(bigquery-jdbc): isolate OpenTelemetry SDK cache keys and shutdown lifecycle - #15347
keshavdandeva wants to merge 4 commits into
Conversation
…tryTransportConfig
… in BigQueryConnectionTest
There was a problem hiding this comment.
Code Review
This pull request introduces TelemetrySdkCacheKey to manage and cache driver-managed OpenTelemetrySdk instances, segregating them by project, universe domain, credential identity, proxy settings, and trust store coordinates without storing plaintext secrets. It also adds a shutdown hook to clean up cached SDKs on JVM shutdown. A review comment identifies a potential NullPointerException in TelemetrySdkCacheKey.java if the GOOGLE_APPLICATION_CREDENTIALS environment variable is not set, suggesting a null check before calling BigQueryJdbcOAuthUtility.isFileExists.
| if (BigQueryJdbcOAuthUtility.isFileExists(adcPath)) { | ||
| putFileDigest(hasher, adcPath); | ||
| } |
There was a problem hiding this comment.
The environment variable GOOGLE_APPLICATION_CREDENTIALS may not be set in all environments, causing System.getenv(...) to return null. Passing a null path to BigQueryJdbcOAuthUtility.isFileExists can lead to a NullPointerException depending on its internal implementation (e.g., if it attempts to instantiate a File or Path object with a null argument). Adding an explicit null check for adcPath prevents this potential crash.
| if (BigQueryJdbcOAuthUtility.isFileExists(adcPath)) { | |
| putFileDigest(hasher, adcPath); | |
| } | |
| if (adcPath != null && BigQueryJdbcOAuthUtility.isFileExists(adcPath)) { | |
| putFileDigest(hasher, adcPath); | |
| } |
Summary
Extracts
TelemetrySdkCacheKeyto segregate driver-managedOpenTelemetrySdkinstances acrossuniverseDomain, credentials, proxy, TrustStore, and OAuth overrides without storing plaintext secrets, and replaces per-SDK JVM shutdown hooks with a single concurrent shutdown hook.Key Decisions
enableGcpTraceExporter=false) configure no exporters and now key solely onprojectIdto avoid unnecessary SDK duplication across differing transport configs.TelemetrySdkCacheKeyhashes immutable credential fields via SHA-256 (gcpTelemetryCredentialsbytes/content,ServiceAccountCredentials, refresh-tokenUserCredentials,ComputeEngineCredentials,ImpersonatedCredentialsviatoBuilder()including ordereddelegates,scopes,lifetime,iamEndpointOverride, and nested sources, and ADCExternalAccountCredentialsvia a singleboolean applicationDefaultCredentialsflag onTelemetryTransportConfig). CustomCredentialssubclasses fall back to object-reference identity.ProxyUid/ProxyPwd(rejected eagerly when trace export is on),SSLTrustStorePwd(store is identified by path/type/provider), and ambient OTel system properties..disableShutdownHook()) and registers one static hook callingshutdownAllSdks(), which initiatessdk.shutdown()on all active cached SDKs concurrently and awaitsCompletableResultCode.ofAll(...)up to 10s.Behavior Changes
universeDomain, credentials,ProxyHost/ProxyPort,SSLTrustStore*, orOAUTH2token URI override no longer share a trace-exportingOpenTelemetrySdk; pooled connections with identicalImpersonatedCredentialsor Drive-scoped ADCExternalAccountCredentialscontinue to share one SDK.enableGcpTraceExporter=false,enableGcpLogExporter=true) for the same project share a single no-exporter SDK regardless of transport or credential differences.