File tree Expand file tree Collapse file tree 2 files changed +7
-10
lines changed
main/java/com/google/gcloud/bigquery
test/java/com/google/gcloud/bigquery Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -128,22 +128,19 @@ public boolean exists() {
128128
129129 /**
130130 * Checks if this job has completed its execution, either failing or succeeding. If the job does
131- * not exist this method returns {@code false}. To correctly wait for job's completion check that
132- * the job exists first, using {@link #exists()}:
131+ * not exist this method returns {@code true}. You can wait for job completion with:
133132 * <pre> {@code
134- * if (job.exists()) {
135- * while(!job.isDone()) {
136- * Thread.sleep(1000L);
137- * }
133+ * while(!job.isDone()) {
134+ * Thread.sleep(1000L);
138135 * }}</pre>
139136 *
140- * @return {@code true} if this job is in {@link JobStatus.State#DONE} state, {@code false} if the
141- * state is not {@link JobStatus.State#DONE} or the job does not exist
137+ * @return {@code true} if this job is in {@link JobStatus.State#DONE} state or if it does not
138+ * exist, {@code false} if the state is not {@link JobStatus.State#DONE}
142139 * @throws BigQueryException upon failure
143140 */
144141 public boolean isDone () {
145142 Job job = bigquery .getJob (jobId (), BigQuery .JobOption .fields (BigQuery .JobField .STATUS ));
146- return job != null && job .status ().state () == JobStatus .State .DONE ;
143+ return job == null || job .status ().state () == JobStatus .State .DONE ;
147144 }
148145
149146 /**
Original file line number Diff line number Diff line change @@ -172,7 +172,7 @@ public void testIsDone_NotExists() throws Exception {
172172 expect (bigquery .getJob (JOB_INFO .jobId (), expectedOptions )).andReturn (null );
173173 replay (bigquery );
174174 initializeJob ();
175- assertFalse (job .isDone ());
175+ assertTrue (job .isDone ());
176176 }
177177
178178 @ Test
You can’t perform that action at this time.
0 commit comments