Skip to content

Conversation

@logachev
Copy link
Contributor

@logachev logachev commented Feb 5, 2026

Add wrappers for log calls requiring String.format() to ensure it is not used directly but passed to the lambda instead.

Update all logging that was using System.format() to use new wrappers. I see some perf gains for both rest & read APIs (~10-15% rows/second, but would wait for internal perf framework runs to have a better idea)

@product-auto-label product-auto-label bot added size: l Pull request size is large. api: bigquery Issues related to the googleapis/java-bigquery API. labels Feb 5, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @logachev, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on a significant performance optimization within the BigQuery JDBC driver's logging infrastructure. By transitioning from immediate string formatting to a deferred approach, the driver now avoids unnecessary string allocations for log messages that would not be displayed due to the current log level. This change enhances efficiency, particularly in environments with verbose logging configurations, ensuring that resources are only consumed when log output is genuinely required.

Highlights

  • Logging Optimization: Refactored numerous logging calls across the codebase to avoid eager string formatting. Instead of String.format(...) being called directly, log methods now accept a format string and arguments, allowing the logging framework to defer string construction until the message is actually logged, improving performance when log levels are set higher.
  • New Logging Methods: Introduced new overloaded methods in BigQueryJdbcCustomLogger (e.g., finest, info, warning, severe) that accept a format string and variable arguments, facilitating the deferred formatting optimization.
  • Driver Logging Configuration: Modified the BigQueryDriver to explicitly separate the setting of the log level from the enablement of file logging, providing clearer control over logging configuration.
Changelog
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryArrowResultSet.java
    • Updated close() method to use deferred string formatting for log messages.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseResultSet.java
    • Updated close() method to use deferred string formatting for log messages.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryCallableStatement.java
    • Updated registerOutParameter methods to use deferred string formatting for LOG.finest calls.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryConnection.java
    • Updated addOpenStatements, createStatement, prepareStatement, and prepareCall methods to use deferred string formatting for log messages.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDatabaseMetaData.java
    • Refactored numerous LOG.info, LOG.warning, LOG.finer, and LOG.severe calls across various metadata retrieval and processing methods to utilize deferred string formatting.
    • Removed an initial check for null/empty catalog or patterns in getProcedures.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDriver.java
    • Modified driver initialization to separate BigQueryJdbcRootLogger.setLevel from BigQueryJdbcRootLogger.enableFileLogger.
    • Updated driver information logging to use deferred string formatting.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcCustomLogger.java
    • Added new void methods (finest, finer, fine, config, info, warning, severe) that accept a format string and Object... args for deferred message formatting.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOAuthUtility.java
    • Updated logging calls in getGoogleUserAccountCredentials and getApplicationDefaultCredentials to use deferred string formatting.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcUrlUtility.java
    • Updated logging calls in appendPropertiesToURL, parseIntProperty, parseLogLevel, parseJobCreationMode, and parsePropertiesMap to use deferred string formatting.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJsonResultSet.java
    • Updated close() method to use deferred string formatting for log messages.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryParameterHandler.java
    • Updated configureParameters and setParameter methods to use deferred string formatting for log messages.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPooledConnection.java
    • Updated fireConnectionError method to use deferred string formatting for log messages.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPreparedStatement.java
    • Updated setInsertMetadata and getStandardBatchJobConfiguration methods to use deferred string formatting for log messages.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java
    • Updated getQueryType, close, cancel, processQueryResponse, processJsonResultSet, runNextPageTaskAsync, parseAndPopulateRpcDataAsync, getDestinationTable, and checkIfDatasetExistElseCreate methods to use deferred string formatting for log messages.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryThreadFactory.java
    • Updated newThread method to use deferred string formatting for log messages.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryTypeCoercer.java
    • Updated coerceTo method to use deferred string formatting for log messages.
  • google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/PooledConnectionListener.java
    • Updated connectionErrorOccurred method to use deferred string formatting for log messages.
Activity
  • The pull request description is empty, and there are no comments or reviews provided in the context, indicating no human activity recorded for this PR yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@logachev logachev force-pushed the kirl/format_logging branch from 99949c1 to 8d758f8 Compare February 5, 2026 21:02
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aims to improve logging performance by avoiding unnecessary String.format calls and introducing new logger methods for lazy parameterized message handling. However, a critical security vulnerability has been identified: the driver logs sensitive data (including auth tokens, passwords, and query parameter values) at the INFO level, leading to high-severity sensitive data exposure. Additionally, a critical bug was introduced in BigQueryDatabaseMetaData.java where the schemaRegex variable was removed but is still referenced, which will cause a compilation error. Beyond these, the refactoring for String.format calls appears incomplete in BigQueryDatabaseMetaData.java, a functional change removed a null-check in the same file, and a typo was introduced in a log message in PooledConnectionListener.java.

I am having trouble creating individual review comments. Click here to see my feedback.

google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcUrlUtility.java (604)

security-high high

The appendPropertiesToURL method logs all connection properties at the INFO level. These properties can include highly sensitive information such as OAuthAccessToken, OAuthRefreshToken, and ProxyPwd. Logging these secrets in plain text poses a significant security risk as they may be accessible to unauthorized individuals through log files or monitoring systems. It is recommended to change the log level to FINEST or implement a masking mechanism for sensitive keys.

        LOG.finest("Appending %s with value %s to URL", entry.getKey(), entry.getValue());

google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryParameterHandler.java (62-64)

security-high high

The configureParameters method logs the values of all query parameters at the INFO level. If a query contains sensitive data (e.g., passwords, PII) as parameters, this information will be written to the logs in plain text. It is recommended to change the log level to FINEST to ensure these values are only logged when deep debugging is enabled, consistent with other parts of the driver.

        LOG.finest(
            "Parameter %s of type %s at index %s added to QueryJobConfiguration",
            parameterValue, sqlType, i);

google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDatabaseMetaData.java (786-791)

high

This check for null/empty catalog and empty patterns was removed. This seems to be an unintended functional change as part of a logging refactoring. Other similar methods like getProcedureColumns retain this check. Removing it might lead to unexpected behavior or NullPointerExceptions if catalog is null and used later. Please consider if this removal was intentional.

google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/PooledConnectionListener.java (121)

medium

There appears to be a typo in this log message. 'dor:' should likely be 'due to error:'.

    LOG.finest("Removed pooled connection from connection pool due to error: %s", errorMessage);

@logachev logachev force-pushed the kirl/format_logging branch from 8d758f8 to 4853e99 Compare February 5, 2026 21:04
@logachev logachev force-pushed the kirl/format_logging branch from 4853e99 to cb6949b Compare February 5, 2026 21:10
@logachev
Copy link
Contributor Author

logachev commented Feb 5, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aims to improve logging performance by removing explicit String.format calls and using deferred formatting. While this is a good practice, a critical security vulnerability was identified: sensitive information, including full connection URLs with credentials and query parameter values, is being logged. The most critical findings involve logging the full connection URL at fine and warning levels in BigQueryJdbcUrlUtility.java, which poses a significant security risk. Additionally, the implementation of new logging methods in BigQueryJdbcCustomLogger can be made more efficient, and there are still instances where string concatenation happens before the log call, and some String.format calls were missed during the refactoring.

@logachev logachev marked this pull request as ready for review February 5, 2026 22:03
@logachev logachev requested review from a team as code owners February 5, 2026 22:03
@logachev logachev added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Feb 6, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Feb 6, 2026
@logachev logachev merged commit ad438dc into main Feb 6, 2026
26 checks passed
@logachev logachev deleted the kirl/format_logging branch February 6, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigquery Issues related to the googleapis/java-bigquery API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants