Skip to content

Commit bf2aba5

Browse files
committed
nit
1 parent 940aaa6 commit bf2aba5

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5279,7 +5279,7 @@ static Future<?>[] wrapThread(final Thread thread) {
52795279
private volatile boolean cancelled = false;
52805280

52815281
@Override
5282-
public boolean cancel(boolean mayInterruptIfRunning) {
5282+
public synchronized boolean cancel(boolean mayInterruptIfRunning) {
52835283
if (cancelled || thread.getState() == Thread.State.TERMINATED) {
52845284
return false;
52855285
}
@@ -5309,7 +5309,11 @@ public Object get() throws InterruptedException, CancellationException {
53095309
if (isCancelled()) {
53105310
throw new CancellationException();
53115311
}
5312-
thread.join(50);
5312+
if (thread.getState() == Thread.State.NEW) {
5313+
Thread.sleep(50);
5314+
} else {
5315+
thread.join(50);
5316+
}
53135317
}
53145318
return null;
53155319
}
@@ -5333,7 +5337,12 @@ public Object get(long timeout, TimeUnit unit)
53335337
if (remainingMillis <= 0) {
53345338
remainingMillis = 1;
53355339
}
5336-
thread.join(Math.min(remainingMillis, 50));
5340+
long delay = Math.min(remainingMillis, 50);
5341+
if (thread.getState() == Thread.State.NEW) {
5342+
Thread.sleep(delay);
5343+
} else {
5344+
thread.join(delay);
5345+
}
53375346
remainingNanos = deadline - System.nanoTime();
53385347
}
53395348
return null;

0 commit comments

Comments
 (0)