Skip to content

Commit f27290b

Browse files
committed
addressed PR feedback
1 parent b4d9811 commit f27290b

4 files changed

Lines changed: 20 additions & 3 deletions

File tree

client/src/main/java/com/microsoft/durabletask/DurableHttpRequest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public DurableHttpRequest(String method, URI uri, @Nullable Map<String, String>
150150
@JsonProperty("headers") @Nullable Map<String, String> headers,
151151
@JsonProperty("content") @Nullable String content,
152152
@JsonProperty("tokenSource") @Nullable TokenSource tokenSource,
153-
@JsonProperty("asynchronousPatternEnabled") boolean asynchronousPatternEnabled,
153+
@JsonProperty("asynchronousPatternEnabled") @Nullable Boolean asynchronousPatternEnabled,
154154
@JsonProperty("timeout") @Nullable String timeout,
155155
@JsonProperty("retryOptions") @Nullable HttpRetryOptions httpRetryOptions) {
156156
if (method == null || method.trim().isEmpty()) {
@@ -164,7 +164,8 @@ public DurableHttpRequest(String method, URI uri, @Nullable Map<String, String>
164164
this.headers = headers != null ? Collections.unmodifiableMap(new HashMap<>(headers)) : null;
165165
this.content = content;
166166
this.tokenSource = tokenSource;
167-
this.asynchronousPatternEnabled = asynchronousPatternEnabled;
167+
this.asynchronousPatternEnabled = asynchronousPatternEnabled != null
168+
? asynchronousPatternEnabled : true;
168169
this.timeout = timeout;
169170
this.httpRetryOptions = httpRetryOptions;
170171
}

client/src/main/java/com/microsoft/durabletask/HttpRetryOptions.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,12 @@ public List<Integer> getStatusCodesToRetry() {
168168
* Sets the maximum retry interval.
169169
*
170170
* @param maxRetryInterval the maximum duration between retries
171+
* @throws IllegalArgumentException if maxRetryInterval is negative or zero
171172
*/
172173
public void setMaxRetryInterval(Duration maxRetryInterval) {
174+
if (maxRetryInterval != null && (maxRetryInterval.isNegative() || maxRetryInterval.isZero())) {
175+
throw new IllegalArgumentException("maxRetryInterval must be positive");
176+
}
173177
this.maxRetryInterval = maxRetryInterval;
174178
}
175179

client/src/main/java/com/microsoft/durabletask/ManagedIdentityTokenSource.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.fasterxml.jackson.annotation.JsonProperty;
99

1010
import javax.annotation.Nullable;
11+
import java.util.Locale;
1112

1213
/**
1314
* A {@link TokenSource} implementation that uses Azure Managed Identity to acquire OAuth 2.0 access tokens.
@@ -132,8 +133,10 @@ public ManagedIdentityOptions getOptions() {
132133
* Auto-normalizes well-known Azure resource URIs by appending {@code /.default} if not present.
133134
*/
134135
private static String normalizeResource(String resource) {
136+
String lowerResource = resource.toLowerCase(Locale.ROOT);
135137
for (String base : KNOWN_RESOURCE_BASES) {
136-
if (resource.startsWith(base) && !resource.endsWith(DEFAULT_SUFFIX)) {
138+
if ((lowerResource.equals(base) || lowerResource.startsWith(base + "/"))
139+
&& !lowerResource.endsWith(DEFAULT_SUFFIX)) {
137140
return resource + DEFAULT_SUFFIX;
138141
}
139142
}

client/src/test/java/com/microsoft/durabletask/DurableHttpRequestTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package com.microsoft.durabletask;
44

55
import com.fasterxml.jackson.databind.ObjectMapper;
6+
import org.junit.jupiter.api.DisplayName;
67
import org.junit.jupiter.api.Test;
78

89
import java.net.URI;
@@ -184,6 +185,14 @@ void serializeWithTokenSourceIncludesKindAndResource() throws Exception {
184185

185186
// ---- JSON deserialization tests ----
186187

188+
@Test
189+
@DisplayName("deserialize: omitted asynchronousPatternEnabled defaults to true")
190+
void deserializeWithoutAsyncPattern_defaultsToTrue() throws Exception {
191+
String json = "{\"method\":\"GET\",\"uri\":\"https://example.com\"}";
192+
DurableHttpRequest req = mapper.readValue(json, DurableHttpRequest.class);
193+
assertTrue(req.isAsynchronousPatternEnabled());
194+
}
195+
187196
@Test
188197
void deserializeMinimalRequest() throws Exception {
189198
String json = "{\"method\":\"GET\",\"uri\":\"https://example.com\",\"asynchronousPatternEnabled\":true}";

0 commit comments

Comments
 (0)