From 25c524aa0f3707dd20d135d8c173c12335dd5050 Mon Sep 17 00:00:00 2001 From: siri-varma Date: Mon, 12 May 2025 20:04:17 -0700 Subject: [PATCH 1/3] Fix NPE Signed-off-by: siri-varma --- client/src/main/java/io/dapr/durabletask/RetryPolicy.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/main/java/io/dapr/durabletask/RetryPolicy.java b/client/src/main/java/io/dapr/durabletask/RetryPolicy.java index 6f1bc4b2..3939c8b0 100644 --- a/client/src/main/java/io/dapr/durabletask/RetryPolicy.java +++ b/client/src/main/java/io/dapr/durabletask/RetryPolicy.java @@ -109,8 +109,8 @@ public RetryPolicy setMaxRetryInterval(@Nullable Duration maxRetryInterval) { * @return this retry policy object */ public RetryPolicy setRetryTimeout(Duration retryTimeout) { - if (retryTimeout != null && retryTimeout.compareTo(this.firstRetryInterval) < 0) { - throw new IllegalArgumentException("The value for retryTimeout must be greater than or equal to the value for firstRetryInterval."); + if (retryTimeout == null || retryTimeout.compareTo(this.firstRetryInterval) < 0) { + throw new IllegalArgumentException("The value for retryTimeout cannot be null and must be greater than or equal to the value for firstRetryInterval."); } this.retryTimeout = retryTimeout; return this; From 01717a3c47ddf2031e1b68917aa9bb3aa0d7cc69 Mon Sep 17 00:00:00 2001 From: siri-varma Date: Mon, 12 May 2025 20:11:47 -0700 Subject: [PATCH 2/3] Fix things Signed-off-by: siri-varma --- .../TaskOrchestrationExecutor.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/client/src/main/java/io/dapr/durabletask/TaskOrchestrationExecutor.java b/client/src/main/java/io/dapr/durabletask/TaskOrchestrationExecutor.java index 388de14f..0c270dd9 100644 --- a/client/src/main/java/io/dapr/durabletask/TaskOrchestrationExecutor.java +++ b/client/src/main/java/io/dapr/durabletask/TaskOrchestrationExecutor.java @@ -1151,24 +1151,27 @@ public V await() { // At that point, we break the `await()` on the child task. // Therefore, once we return from the following `await`, // we just need to await again on the *current* child task to obtain the result of this task + try{ - this.getChildTask().await(); + return this.getChildTask().await(); } catch (OrchestratorBlockedException ex) { throw ex; - } catch (Exception ignored) { - // ignore the exception from previous child tasks. - // Only needs to return result from the last child task, which is on next line. + } catch (Exception ex) { } - // Always return the last child task result. + return this.getChildTask().await(); } private boolean shouldRetry() { if (this.lastFailure.isNonRetriable()) { - return false; + logger.warning("Not performing any retries because the error is non retriable"); + + return false; } if (this.policy != null) { + logger.warning("Performing retires based on policy"); + return this.shouldRetryBasedOnPolicy(); } else if (this.handler != null) { RetryContext retryContext = new RetryContext( @@ -1184,6 +1187,8 @@ private boolean shouldRetry() { } private boolean shouldRetryBasedOnPolicy() { + logger.warning(this.attemptNumber + " retries out of total %d performed " + this.policy.getMaxNumberOfAttempts()); + if (this.attemptNumber >= this.policy.getMaxNumberOfAttempts()) { // Max number of attempts exceeded return false; @@ -1191,9 +1196,11 @@ private boolean shouldRetryBasedOnPolicy() { // Duration.ZERO is interpreted as no maximum timeout Duration retryTimeout = this.policy.getRetryTimeout(); + if (retryTimeout.compareTo(Duration.ZERO) > 0) { Instant retryExpiration = this.firstAttempt.plus(retryTimeout); if (this.context.getCurrentInstant().compareTo(retryExpiration) >= 0) { + // Max retry timeout exceeded return false; } @@ -1374,6 +1381,7 @@ public boolean completeExceptionally(Throwable ex) { Task parentTask = this.getParentTask(); boolean result = this.future.completeExceptionally(ex); if (parentTask instanceof RetriableTask) { + // notify parent task ((RetriableTask) parentTask).handleChildException(ex); } From 4a2a08ef343eb8b771b7d74d205591dbc701bf7b Mon Sep 17 00:00:00 2001 From: siri-varma Date: Mon, 12 May 2025 20:14:26 -0700 Subject: [PATCH 3/3] Fix things Signed-off-by: siri-varma --- .../dapr/durabletask/TaskOrchestrationExecutor.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/client/src/main/java/io/dapr/durabletask/TaskOrchestrationExecutor.java b/client/src/main/java/io/dapr/durabletask/TaskOrchestrationExecutor.java index 0c270dd9..7191ebb8 100644 --- a/client/src/main/java/io/dapr/durabletask/TaskOrchestrationExecutor.java +++ b/client/src/main/java/io/dapr/durabletask/TaskOrchestrationExecutor.java @@ -1151,14 +1151,15 @@ public V await() { // At that point, we break the `await()` on the child task. // Therefore, once we return from the following `await`, // we just need to await again on the *current* child task to obtain the result of this task - try{ - return this.getChildTask().await(); + this.getChildTask().await(); } catch (OrchestratorBlockedException ex) { throw ex; - } catch (Exception ex) { + } catch (Exception ignored) { + // ignore the exception from previous child tasks. + // Only needs to return result from the last child task, which is on next line. } - + // Always return the last child task result. return this.getChildTask().await(); } @@ -1196,11 +1197,9 @@ private boolean shouldRetryBasedOnPolicy() { // Duration.ZERO is interpreted as no maximum timeout Duration retryTimeout = this.policy.getRetryTimeout(); - if (retryTimeout.compareTo(Duration.ZERO) > 0) { Instant retryExpiration = this.firstAttempt.plus(retryTimeout); if (this.context.getCurrentInstant().compareTo(retryExpiration) >= 0) { - // Max retry timeout exceeded return false; } @@ -1381,7 +1380,6 @@ public boolean completeExceptionally(Throwable ex) { Task parentTask = this.getParentTask(); boolean result = this.future.completeExceptionally(ex); if (parentTask instanceof RetriableTask) { - // notify parent task ((RetriableTask) parentTask).handleChildException(ex); }