FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: Close bq read client by naung9 · Pull Request #3644 · googleapis/java-bigquery · GitHub

This repository was archived by the owner on Mar 23, 2026. It is now read-only.
/ java-bigquery Public archive
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class ConnectionImpl implements Connection {
private final Logger logger = Logger.getLogger(this.getClass().getName());
private BigQueryReadClient bqReadClient;
private static final long EXECUTOR_TIMEOUT_SEC = 10;
private static final long BIGQUERY_TIMEOUT_SEC = 10;
private BlockingQueue<AbstractList<FieldValue>>
bufferFvl; // initialized lazily iff we end up using the tabledata.list end point
private BlockingQueue<BigQueryResultImpl.Row>
Expand Down Expand Up @@ -148,8 +149,15 @@ public synchronized boolean close() throws BigQuerySQLException {
flagEndOfStream(); // an End of Stream flag in the buffer so that the `ResultSet.next()` stops
// advancing the cursor
queryTaskExecutor.shutdownNow();
boolean isBqReadClientTerminated = true;
try {
if (queryTaskExecutor.awaitTermination(EXECUTOR_TIMEOUT_SEC, TimeUnit.SECONDS)) {
if (bqReadClient != null) {
bqReadClient.shutdownNow();
isBqReadClientTerminated =
bqReadClient.awaitTermination(BIGQUERY_TIMEOUT_SEC, TimeUnit.SECONDS);
}
if (queryTaskExecutor.awaitTermination(EXECUTOR_TIMEOUT_SEC, TimeUnit.SECONDS)
&& isBqReadClientTerminated) {
return true;
} // else queryTaskExecutor.isShutdown() will be returned outside this try block
} catch (InterruptedException e) {
Expand All @@ -159,7 +167,9 @@ public synchronized boolean close() throws BigQuerySQLException {
e); // Logging InterruptedException instead of throwing the exception back, close method
// will return queryTaskExecutor.isShutdown()
}
return queryTaskExecutor.isShutdown(); // check if the executor has been shutdown

return queryTaskExecutor.isShutdown()
&& isBqReadClientTerminated; // check if the executor has been shutdown
}

/**
Expand Down Expand Up @@ -985,7 +995,6 @@ BigQueryResult highThroughPutRead(
// DO a regex check using order by and use multiple streams
;
ReadSession readSession = bqReadClient.createReadSession(builder.build());

bufferRow = new LinkedBlockingDeque<>(getBufferSize());
Map<String, Integer> arrowNameToIndex = new HashMap<>();
// deserialize and populate the buffer async, so that the client isn't blocked
Expand Down Expand Up @@ -1042,6 +1051,7 @@ private void processArrowStreamAsync(
"\n" + Thread.currentThread().getName() + " Interrupted @ markLast",
e);
}
bqReadClient.shutdownNow(); // Shutdown the read client
queryTaskExecutor.shutdownNow(); // Shutdown the thread pool
}
};
Expand Down

Back | FazBrowse Home | New Git URL