File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed
main/java/com/google/gcloud/compute
test/java/com/google/gcloud/compute Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -640,23 +640,21 @@ public boolean exists() throws ComputeException {
640
640
641
641
/**
642
642
* Checks if this operation has completed its execution, either failing or succeeding. If the
643
- * operation does not exist this method returns {@code false }. To correctly wait for operation's
644
- * completion, check that the operation exists first using {@link #exists()} :
643
+ * operation does not exist this method returns {@code true }. You can wait for operation
644
+ * completion with :
645
645
* <pre> {@code
646
- * if (operation.exists()) {
647
- * while(!operation.isDone()) {
648
- * Thread.sleep(1000L);
649
- * }
646
+ * while(!operation.isDone()) {
647
+ * Thread.sleep(1000L);
650
648
* }}</pre>
651
649
*
652
- * @return {@code true} if this operation is in {@link Operation.Status#DONE} state, {@code false}
653
- * if the state is not {@link Operation.Status#DONE} or the operation does not exist
650
+ * @return {@code true} if this operation is in {@link Operation.Status#DONE} state or if it does
651
+ * not exist, {@code false} if the state is not {@link Operation.Status#DONE}
654
652
* @throws ComputeException upon failure
655
653
*/
656
654
public boolean isDone () throws ComputeException {
657
655
Operation operation =
658
656
compute .get (operationId , Compute .OperationOption .fields (Compute .OperationField .STATUS ));
659
- return operation != null && operation .status () == Status .DONE ;
657
+ return operation == null || operation .status () == Status .DONE ;
660
658
}
661
659
662
660
/**
Original file line number Diff line number Diff line change @@ -352,7 +352,7 @@ public void testIsDone_NotExists() throws Exception {
352
352
expect (compute .get (GLOBAL_OPERATION_ID , expectedOptions )).andReturn (null );
353
353
replay (compute );
354
354
initializeOperation ();
355
- assertFalse (operation .isDone ());
355
+ assertTrue (operation .isDone ());
356
356
verify (compute );
357
357
}
358
358
You can’t perform that action at this time.
0 commit comments