Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfa0a12e

Browse files
authored
fix: Job.isDone() uses Job.Status.State if available (#4039)
1 parent7198340 commitfa0a12e

File tree

2 files changed

+12
-5
lines changed
  • google-cloud-bigquery/src

2 files changed

+12
-5
lines changed

‎google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Job.java‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ public boolean exists() {
210210
*/
211211
publicbooleanisDone() {
212212
checkNotDryRun("isDone");
213+
if (hasDoneState()) {
214+
returntrue;
215+
}
213216
SpanisDone =null;
214217
if (options.isOpenTelemetryTracingEnabled() &&options.getOpenTelemetryTracer() !=null) {
215218
isDone =
@@ -220,14 +223,18 @@ public boolean isDone() {
220223
}
221224
try (ScopeisDoneScope =isDone !=null ?isDone.makeCurrent() :null) {
222225
Jobjob =bigquery.getJob(getJobId(),JobOption.fields(BigQuery.JobField.STATUS));
223-
returnjob ==null ||JobStatus.State.DONE.equals(job.getStatus().getState());
226+
returnjob ==null ||job.hasDoneState();
224227
}finally {
225228
if (isDone !=null) {
226229
isDone.end();
227230
}
228231
}
229232
}
230233

234+
privatebooleanhasDoneState() {
235+
returngetStatus() !=null &&JobStatus.State.DONE.equals(getStatus().getState());
236+
}
237+
231238
/** See {@link #waitFor(BigQueryRetryConfig, RetryOption...)} */
232239
publicJobwaitFor(RetryOption...waitOptions)throwsInterruptedException {
233240
returnwaitForInternal(DEFAULT_RETRY_CONFIG,waitOptions);

‎google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/JobTest.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,9 @@ public void testExists_False() {
157157

158158
@Test
159159
publicvoidtestIsDone_True() {
160-
BigQuery.JobOption[]expectedOptions = {BigQuery.JobOption.fields(BigQuery.JobField.STATUS)};
161160
Jobjob =expectedJob.toBuilder().setStatus(newJobStatus(JobStatus.State.DONE)).build();
162-
when(bigquery.getJob(JOB_INFO.getJobId(),expectedOptions)).thenReturn(job);
163161
assertTrue(job.isDone());
164-
verify(bigquery).getJob(JOB_INFO.getJobId(),expectedOptions);
162+
verify(bigquery,times(0)).getJob(eq(JOB_INFO.getJobId()),any());
165163
}
166164

167165
@Test
@@ -176,8 +174,10 @@ public void testIsDone_False() {
176174
@Test
177175
publicvoidtestIsDone_NotExists() {
178176
BigQuery.JobOption[]expectedOptions = {BigQuery.JobOption.fields(BigQuery.JobField.STATUS)};
177+
JobjobWithRunningState =
178+
expectedJob.toBuilder().setStatus(newJobStatus(JobStatus.State.RUNNING)).build();
179179
when(bigquery.getJob(JOB_INFO.getJobId(),expectedOptions)).thenReturn(null);
180-
assertTrue(job.isDone());
180+
assertTrue(jobWithRunningState.isDone());
181181
verify(bigquery).getJob(JOB_INFO.getJobId(),expectedOptions);
182182
}
183183

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp