Repository navigation
Conversation
…UrlLogPath option PR 4 of 6 in the diagnostic logging series (b/584840083, part 1 of 2). Applies BigQueryConnection.SAFE_TO_LOG_PROPERTIES allowlist masking in BigQueryJdbcUrlUtility.appendPropertiesToURL, binds reentrant BigQueryJdbcMdc context at the start of BigQueryDriver.connect with failure cleanup, and adds -Dcom.google.cloud.bigquery.jdbc.allowUrlLogPath.
There was a problem hiding this comment.
Code Review
This pull request introduces a new system property, com.google.cloud.bigquery.jdbc.allowUrlLogPath, to control whether the LogPath parameter supplied via the JDBC URL or connection properties is honored. It also refactors logging to mask sensitive properties, introduces connection-specific MDC logging with nested context support, and adds comprehensive unit tests. The code review feedback highlights several key areas for improvement: addressing a race condition in BigQueryJdbcRootLogger where closing the global static fileHandler can disrupt logging for other active connections, performing case-insensitive lookups for safe logging properties to prevent unnecessary masking, wrapping System.getProperty in a try-catch block to handle potential SecurityExceptions under a Security Manager, and sorting properties before appending them to the URL to ensure deterministic output.
Summary
PR 4 of 6 in the diagnostic logging stack (
b/584840083, part 1 of 2; stacked onfix/bq-jdbc-log-handler-lifecycle). Applies allowlist property masking during URL assembly, binds reentrant MDC context from the start ofBigQueryDriver.connect, and adds-Dcom.google.cloud.bigquery.jdbc.allowUrlLogPath.Environment Variables & System Properties
-Dcom.google.cloud.bigquery.jdbc.allowUrlLogPath=<true|false>(default:true). When set tofalse,LogPathsupplied via the JDBC URL orPropertiesis ignored (logging aWARNINGwithout failingconnect()) and implicit fallback to the current working directory is disabled so local log files are written only whenBIGQUERY_JDBC_LOG_PATHis configured in the environment. Documented inREADME.MDanddocs/USER_GUIDE.md.Design Decisions
maskPropertyValueacross URL & connection logging: Centralizes property redaction onBigQueryConnection.SAFE_TO_LOG_PROPERTIES(excludingBYOID_CredentialSource) and reusesBigQueryConnection.maskPropertyValueinsideBigQueryJdbcUrlUtility.appendPropertiesToURLvia lazySupplier<String>logging atFINEST, ensuring unrecognized or credential-bearingPropertiesentries are masked consistently.allowUrlLogPathswitch (defaulttrue): Multi-connection server deployments that accept caller-supplied JDBC URLs need a JVM-wide way to keep filesystem log output controlled strictly by host environment variables (BIGQUERY_JDBC_LOG_PATH), while standalone tools and existing integrations retain full backward compatibility by default (true) and connections never fail when URLLogPathis ignored.BigQueryJdbcMdc& earlyconnectionIdallocation: AllocatesconnectionIdat the top ofBigQueryDriver.connectso URL parsing and connection setup logs carry the connection ID, while saving and restoring any outer MDC context onMdcCloseable.close()for nested connection creation.