fix(bqjdbc): Log exception messages - part 3#12920
Conversation
There was a problem hiding this comment.
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.
…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>
I updated the exception message boiler plate with the existing infra. After MDC impl is complete. I will update this loggers to match. |
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:
2. Updates to BigQueryJdbcCustomLogger
To support the above changes, the custom logger was updated:
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:
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:
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.