Skip to content

fix(bigquery-jdbc): fix Exception handling - #14566

Open
Neenu1995 wants to merge 1 commit into
mainfrom
fix-interrupted-exception
Open

Neenu1995 wants to merge 1 commit into
mainfrom
fix-interrupted-exception

Conversation

@Neenu1995

@Neenu1995 Neenu1995 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor
  • Restore the thread's interrupt flag (Thread.currentThread().interrupt()) on every
    InterruptedException catch in Connection, Statement, PreparedStatement, ResultSet,
    DatabaseMetaData and OpenTelemetry tracing.
  • Throw checked BigQueryJdbcException instead of unchecked BigQueryJdbcRuntimeException
    from public JDBC methods (execute*, executeBatch, getMoreResults, next,
    commit, rollback, close, Write API batch), as JDBC requires SQLException.
  • Replace IllegalStateException with BigQueryJdbcException in checkClosed(),
    checkIfEnabledSession(), and commit()/rollback() when no transaction is active.
    Methods that call these checks (getDefaultDataset, getLocation,
    getAuthProperties, getAutoCommit, Statement constructors) now declare
    throws SQLException.
  • Wrap background fetch errors once: worker threads put the raw cause in the buffer,
    and ResultSet.next() wraps it a single time via backgroundFetchError(), keeping
    the BigQueryException cause so its error details stay available.
  • Harden Connection.close(): errors from abortSession() and interrupts while waiting
    for executors to shut down are collected as suppressed exceptions and rethrown as
    BigQueryJdbcException. isClosed is now set even when close throws.
  • Remove throws InterruptedException from runQuery(), which also removes the
    duplicate catch blocks in its callers.
  • Stop the GC daemon polling thread from crashing on interrupt; it now logs the
    exception with its stack trace and restores the interrupt flag.
  • withTracing no longer turns checked exceptions into unchecked ones.
  • Remove the BigQueryJdbcRuntimeException(String, InterruptedException) constructor.
  • Update unit and integration tests to expect SQLException / BigQueryJdbcException.

@Neenu1995
Neenu1995 requested review from a team as code owners October 1, 2026 16:17

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

Copy link
Copy Markdown
Contributor

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 refactors exception handling across the BigQuery JDBC driver, replacing BigQueryJdbcRuntimeException with BigQueryJdbcException to align with standard JDBC practices. It also standardizes InterruptedException handling by consistently restoring the thread's interrupted status and wrapping it appropriately. The review feedback identifies a compilation error in BigQueryDaemonPollingTask due to an invalid logger method overload, suggests preserving descriptive error messages when wrapping InterruptedException in BigQueryJdbcOpenTelemetry, and recommends ensuring an exception is thrown during connection close if the thread was interrupted.

This branch has not been deployed

No deployments
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.

1 participant