private void waitOperationDone(Operation operation) {
AtomicReference<Operation> operationRef = Atomics.newReference(operation);
// wait for the operation to complete
if (!retryOperationDonePredicate.apply(operationRef)) {
throw new UncheckedTimeoutException("operation did not reach DONE state" + operationRef.get());
}
// check if the operation failed
if (operationRef.get().getHttpError().isPresent()) {
HttpResponse response = operationRef.get().getHttpError().get();