Skip to content

Commit fa2a70c

Browse files
committed
fix bridge
1 parent 9a0f70f commit fa2a70c

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

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

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5305,9 +5305,11 @@ public Object get() throws InterruptedException, CancellationException {
53055305
if (isCancelled()) {
53065306
throw new CancellationException();
53075307
}
5308-
thread.join();
5309-
if (isCancelled()) {
5310-
throw new CancellationException();
5308+
while (thread.getState() != Thread.State.TERMINATED) {
5309+
if (isCancelled()) {
5310+
throw new CancellationException();
5311+
}
5312+
thread.join(50);
53115313
}
53125314
return null;
53135315
}
@@ -5318,12 +5320,21 @@ public Object get(long timeout, TimeUnit unit)
53185320
if (isCancelled()) {
53195321
throw new CancellationException();
53205322
}
5321-
unit.timedJoin(thread, timeout);
5322-
if (isCancelled()) {
5323-
throw new CancellationException();
5324-
}
5325-
if (thread.isAlive()) {
5326-
throw new TimeoutException();
5323+
long remainingNanos = unit.toNanos(timeout);
5324+
long deadline = System.nanoTime() + remainingNanos;
5325+
while (thread.getState() != Thread.State.TERMINATED) {
5326+
if (isCancelled()) {
5327+
throw new CancellationException();
5328+
}
5329+
if (remainingNanos <= 0) {
5330+
throw new TimeoutException();
5331+
}
5332+
long remainingMillis = TimeUnit.NANOSECONDS.toMillis(remainingNanos);
5333+
if (remainingMillis <= 0) {
5334+
remainingMillis = 1;
5335+
}
5336+
thread.join(Math.min(remainingMillis, 50));
5337+
remainingNanos = deadline - System.nanoTime();
53275338
}
53285339
return null;
53295340
}

0 commit comments

Comments
 (0)