Skip to content

fix(bqjdbc): Log exception messages - part 3#12920

Open
Neenu1995 wants to merge 11 commits intomainfrom
fix-sever-logs2
Open

fix(bqjdbc): Log exception messages - part 3#12920
Neenu1995 wants to merge 11 commits intomainfrom
fix-sever-logs2

Conversation

@Neenu1995
Copy link
Copy Markdown
Contributor

@Neenu1995 Neenu1995 commented Apr 24, 2026

b/505826451

1. Centralization of Exception Logging

Moved the responsibility of logging exceptions from the throw sites to the constructors of the custom exception classes themselves. This ensures all instances are logged automatically and consistently.

Added loggers and logging calls to constructors of the following custom exception classes:

  • BigQueryJdbcRuntimeException
  • BigQueryJdbcException
  • BigQueryConversionException
  • BigQueryJdbcCoercionException
  • BigQueryJdbcCoercionNotFoundException
  • BigQueryJdbcSqlFeatureNotSupportedException
  • BigQueryJdbcSqlSyntaxErrorException

2. Updates to BigQueryJdbcCustomLogger
To support the above changes, the custom logger was updated:

  • Modified caller inference to skip classes in the com.google.cloud.bigquery.exception package. This ensures that the logs point to the method that threw the exception rather than the exception constructor itself.
  • Made the class, its constructor, and severe methods public so they can be accessed by exception classes residing in a different package.

3. Cleanup of Redundant Logging
After centralizing the logging, removed manual LOG.severe calls that were followed by a throw of the updated custom exceptions in functional classes.

Files cleaned up:

  • BigQueryConnection.java
  • BigQueryStatement.java
  • BigQueryPreparedStatement.java
  • BigQueryJdbcOAuthUtility.java
  • BigQueryArrowResultSet.java
  • BigQueryJsonResultSet.java
  • BigQueryBaseResultSet.java
  • BigQueryTypeCoercer.java
  • BigQueryJdbcTypeMappings.java
  • PooledConnectionDataSource.java

4. Addition of Logging for Standard Exceptions
For standard Java exceptions (like IllegalArgumentException and IllegalStateException) that do not log themselves, added manual severe logging before they are thrown to ensure they are not missed in the logs.

Files updated:

  • BigQueryConnection.java
  • BigQueryCallableStatement.java
  • BigQueryStatement.java.

5. Logger Signature Refactor
Updated BigQueryJdbcCustomLogger.java to take Throwable as the second parameter in severe methods, and updated calls across 17 files to match this signature.

@Neenu1995 Neenu1995 requested review from a team as code owners April 24, 2026 15:54
Copy link
Copy Markdown
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 standardizes exception handling and logging across the BigQuery JDBC driver by ensuring that exceptions are logged at the severe level before being thrown. It introduces loggers to several utility classes and refactors catch blocks to provide more descriptive error messages. Review feedback suggests restoring lost context, specifically the 'catalogParam' variable, in BigQueryDatabaseMetaData and recommends using a static final logger in PooledConnectionDataSource to align with standard practices.

Neenu1995 and others added 6 commits April 24, 2026 12:16
…gle/cloud/bigquery/jdbc/BigQueryDatabaseMetaData.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…gle/cloud/bigquery/jdbc/BigQueryDatabaseMetaData.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…gle/cloud/bigquery/jdbc/PooledConnectionDataSource.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@Neenu1995
Copy link
Copy Markdown
Contributor Author

Neenu1995 commented Apr 27, 2026

When we get Mdc working, can this LOG be a part of the exception? At least for exceptions that we own they could log sever errors, so we'll never forget to log it.

I updated the exception message boiler plate with the existing infra. After MDC impl is complete. I will update this loggers to match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants