Skip to content

Commit 940aaa6

Browse files
committed
exception management
1 parent fa2a70c commit 940aaa6

1 file changed

Lines changed: 29 additions & 4 deletions

File tree

java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,16 @@ ResultSet processArrowResultSet(TableResult results, Job job) throws SQLExceptio
864864
"Failed to execute query: Unable to allocate background threads to process the query results. Connection-scoped thread pool limit of 100 threads was reached or system is out of memory.",
865865
ex);
866866
}
867+
if (ex instanceof RuntimeException) {
868+
throw (ex instanceof BigQueryJdbcRuntimeException)
869+
? (BigQueryJdbcRuntimeException) ex
870+
: new BigQueryJdbcRuntimeException(ex);
871+
}
872+
if (ex instanceof SQLException) {
873+
throw (ex instanceof BigQueryJdbcException)
874+
? (BigQueryJdbcException) ex
875+
: new BigQueryJdbcException(ex);
876+
}
867877
throw new BigQueryJdbcException(ex.getMessage(), ex);
868878
}
869879
}
@@ -1073,6 +1083,8 @@ BigQueryJsonResultSet processJsonResultSet(TableResult results, Job job) throws
10731083
LOG.warning(
10741084
"%s Interrupted @ processJsonQueryResponseResults: %s",
10751085
Thread.currentThread().getName(), e.getMessage());
1086+
Thread.currentThread().interrupt();
1087+
throw new BigQueryJdbcException("Query execution was interrupted.", e);
10761088
}
10771089
}
10781090

@@ -1081,15 +1093,28 @@ BigQueryJsonResultSet processJsonResultSet(TableResult results, Job job) throws
10811093
parseAndPopulateRpcDataAsync(
10821094
schema, this.bigQueryFieldValueListWrapperBlockingQueue, rpcResponseQueue);
10831095
taskList.add(populateBufferWorker);
1084-
} catch (RejectedExecutionException | OutOfMemoryError e) {
1096+
} catch (Exception | OutOfMemoryError e) {
10851097
for (Future<?> task : taskList) {
10861098
if (task != null) {
10871099
task.cancel(true);
10881100
}
10891101
}
1090-
throw new BigQueryJdbcException(
1091-
"Failed to execute query: Unable to allocate background threads to process the query results. Connection-scoped thread pool limit of 100 threads was reached or system is out of memory.",
1092-
e);
1102+
if (e instanceof RejectedExecutionException || e instanceof OutOfMemoryError) {
1103+
throw new BigQueryJdbcException(
1104+
"Failed to execute query: Unable to allocate background threads to process the query results. Connection-scoped thread pool limit of 100 threads was reached or system is out of memory.",
1105+
e);
1106+
}
1107+
if (e instanceof RuntimeException) {
1108+
throw (e instanceof BigQueryJdbcRuntimeException)
1109+
? (BigQueryJdbcRuntimeException) e
1110+
: new BigQueryJdbcRuntimeException(e);
1111+
}
1112+
if (e instanceof SQLException) {
1113+
throw (e instanceof BigQueryJdbcException)
1114+
? (BigQueryJdbcException) e
1115+
: new BigQueryJdbcException(e);
1116+
}
1117+
throw new BigQueryJdbcException(e.getMessage(), e);
10931118
}
10941119

10951120
Future<?>[] jsonWorkers = taskList.toArray(new Future<?>[0]);

0 commit comments

Comments
 (0)