From 6d39069ae81fb2a47edcb61e82d82cabea5c2a8e Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Wed, 13 Apr 2016 10:04:30 +0200 Subject: [PATCH] Compute's Operation.isDone() return true if operation does not exist --- .../com/google/gcloud/compute/Operation.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/gcloud-java-compute/src/main/java/com/google/gcloud/compute/Operation.java b/gcloud-java-compute/src/main/java/com/google/gcloud/compute/Operation.java index 4270147777a6..2b35dac3fd2b 100644 --- a/gcloud-java-compute/src/main/java/com/google/gcloud/compute/Operation.java +++ b/gcloud-java-compute/src/main/java/com/google/gcloud/compute/Operation.java @@ -640,23 +640,21 @@ public boolean exists() throws ComputeException { /** * Checks if this operation has completed its execution, either failing or succeeding. If the - * operation does not exist this method returns {@code false}. To correctly wait for operation's - * completion, check that the operation exists first using {@link #exists()}: + * operation does not exist this method returns {@code true}. You can wait for operation + * completion with: *
 {@code
-   * if (operation.exists()) {
-   *   while(!operation.isDone()) {
-   *     Thread.sleep(1000L);
-   *   }
+   * while(!operation.isDone()) {
+   *   Thread.sleep(1000L);
    * }}
* - * @return {@code true} if this operation is in {@link Operation.Status#DONE} state, {@code false} - * if the state is not {@link Operation.Status#DONE} or the operation does not exist + * @return {@code true} if this operation is in {@link Operation.Status#DONE} state or if it does + * not exist, {@code false} if the state is not {@link Operation.Status#DONE} * @throws ComputeException upon failure */ public boolean isDone() throws ComputeException { Operation operation = compute.get(operationId, Compute.OperationOption.fields(Compute.OperationField.STATUS)); - return operation != null && operation.status() == Status.DONE; + return operation == null || operation.status() == Status.DONE; } /**