Skip to content

Commit 6d39069

Browse files
committed
Compute's Operation.isDone() return true if operation does not exist
1 parent 246e5a7 commit 6d39069

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

  • gcloud-java-compute/src/main/java/com/google/gcloud/compute

gcloud-java-compute/src/main/java/com/google/gcloud/compute/Operation.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -640,23 +640,21 @@ public boolean exists() throws ComputeException {
640640

641641
/**
642642
* 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:
645645
* <pre> {@code
646-
* if (operation.exists()) {
647-
* while(!operation.isDone()) {
648-
* Thread.sleep(1000L);
649-
* }
646+
* while(!operation.isDone()) {
647+
* Thread.sleep(1000L);
650648
* }}</pre>
651649
*
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}
654652
* @throws ComputeException upon failure
655653
*/
656654
public boolean isDone() throws ComputeException {
657655
Operation operation =
658656
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;
660658
}
661659

662660
/**

0 commit comments

Comments
 (0)