Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
}

group 'io.dapr'
version = '1.5.5'
version = '1.5.6'
archivesBaseName = 'durabletask-client'

def grpcVersion = '1.69.0'
Expand Down
2 changes: 1 addition & 1 deletion client/src/main/java/io/dapr/durabletask/TaskOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public final class TaskOptions {
private final RetryPolicy retryPolicy;
private final RetryHandler retryHandler;

private TaskOptions(RetryPolicy retryPolicy, RetryHandler retryHandler) {
public TaskOptions(RetryPolicy retryPolicy, RetryHandler retryHandler) {
this.retryPolicy = retryPolicy;
this.retryHandler = retryHandler;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,8 @@ public <V> Task<V> callSubOrchestrator(

private <V> Task<V> createAppropriateTask(TaskFactory<V> taskFactory, TaskOptions options) {
// Retry policies and retry handlers will cause us to return a RetriableTask<V>
if (options != null && options.hasRetryPolicy()) {
return new RetriableTask<V>(this, taskFactory, options.getRetryPolicy());
} if (options != null && options.hasRetryHandler()) {
return new RetriableTask<V>(this, taskFactory, options.getRetryHandler());
if (options != null && (options.hasRetryPolicy() || options.hasRetryHandler())) {
return new RetriableTask<V>(this, taskFactory, options.getRetryPolicy(), options.getRetryHandler());
} else {
// Return a single vanilla task without any wrapper
return taskFactory.create();
Expand Down Expand Up @@ -1170,25 +1168,34 @@ private boolean shouldRetry() {
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(
this.context,
this.attemptNumber,
this.lastFailure,
this.totalRetryTime);
return this.handler.handle(retryContext);
} else {
if(this.policy == null && this.handler == null) {
// We should never get here, but if we do, returning false is the natural behavior.
return false;
}

RetryContext retryContext = new RetryContext(
this.context,
this.attemptNumber,
this.lastFailure,
this.totalRetryTime);

// These must default to true if not provided, so it is possible to use only one of them at a time
boolean shouldRetryBasedOnPolicy = this.policy != null ? this.shouldRetryBasedOnPolicy() : true;
boolean shouldRetryBasedOnHandler = this.handler != null ? this.handler.handle(retryContext) : true;

if (this.policy != null) {
logger.info(() -> String.format("shouldRetryBasedOnPolicy: %s", shouldRetryBasedOnPolicy));
}

if (this.handler != null) {
logger.info(() -> String.format("shouldRetryBasedOnHandler: %s", shouldRetryBasedOnHandler));
}

return shouldRetryBasedOnPolicy && shouldRetryBasedOnHandler;
}

private boolean shouldRetryBasedOnPolicy() {
logger.warning(() -> String.format("%d retries out of total %d performed ", this.attemptNumber, this.policy.getMaxNumberOfAttempts()));
logger.warning(() -> String.format("Retry Policy: %d retries out of total %d performed ", this.attemptNumber, this.policy.getMaxNumberOfAttempts()));

if (this.attemptNumber >= this.policy.getMaxNumberOfAttempts()) {
// Max number of attempts exceeded
Expand Down
Loading