Skip to content

Commit 96a78ab

Browse files
committed
fix: no null minRetry value allowed
1 parent 8d8da42 commit 96a78ab

3 files changed

Lines changed: 20 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
- feat: RFC 9110 compliant Retry-After header support with exponential backoff and jitter
77
- feat: Enhanced retry strategy with delay calculation
88
- feat: Retry-After header value exposed in error objects for better observability
9+
- feat: Input validation for Configuration.minimumRetryDelay() to prevent negative values
10+
- feat: Default value (100ms) now explicitly set for minimumRetryDelay configuration
911

1012
### Changed
1113
- **BREAKING**: Maximum allowable retry count is now enforced at 15 (default remains 3)
1214
- **BREAKING**: FgaError now exposes Retry-After header value via getRetryAfterHeader() method
15+
- **BREAKING**: Configuration.minimumRetryDelay() now requires non-null values and validates input, throwing IllegalArgumentException for null or negative values
1316

1417
### Technical Details
1518
- Implements RFC 9110 compliant Retry-After header parsing (supports both integer seconds and HTTP-date formats)
@@ -21,6 +24,7 @@
2124
**Migration Guide**:
2225
- Update error handling code if using FgaError properties - new getRetryAfterHeader() method available
2326
- Note: Maximum allowable retries is now enforced at 15 (validation added to prevent exceeding this limit)
27+
- **IMPORTANT**: Configuration.minimumRetryDelay() now requires non-null values and validates input - ensure you're not passing null or negative Duration values, as this will now throw IllegalArgumentException. Previously null values were silently accepted and would fall back to default behavior at runtime.
2428

2529
## v0.8.3
2630

src/main/java/dev/openfga/sdk/api/configuration/Configuration.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,18 +289,26 @@ public Integer getMaxRetries() {
289289
/**
290290
* Sets the minimum delay to wait before retrying a failed request.
291291
*
292-
* @param minimumRetryDelay The minimum delay. Must be non-negative.
292+
* @param minimumRetryDelay The minimum delay. Must be non-null and non-negative.
293293
* @return This Configuration instance for method chaining.
294-
* @throws IllegalArgumentException if minimumRetryDelay is negative.
294+
* @throws IllegalArgumentException if minimumRetryDelay is null or negative.
295295
*/
296296
public Configuration minimumRetryDelay(Duration minimumRetryDelay) {
297-
if (minimumRetryDelay != null && minimumRetryDelay.isNegative()) {
297+
if (minimumRetryDelay == null) {
298+
throw new IllegalArgumentException("minimumRetryDelay cannot be null");
299+
}
300+
if (minimumRetryDelay.isNegative()) {
298301
throw new IllegalArgumentException("minimumRetryDelay cannot be negative");
299302
}
300303
this.minimumRetryDelay = minimumRetryDelay;
301304
return this;
302305
}
303306

307+
/**
308+
* Gets the minimum delay to wait before retrying a failed request.
309+
*
310+
* @return The minimum retry delay. Never null.
311+
*/
304312
@Override
305313
public Duration getMinimumRetryDelay() {
306314
return minimumRetryDelay;

src/test/java/dev/openfga/sdk/api/configuration/ConfigurationTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,12 @@ void minimumRetryDelay_nullValue() {
295295
// Given
296296
Configuration config = new Configuration();
297297

298-
// When
299-
Configuration result = config.minimumRetryDelay(null);
298+
// When & Then
299+
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> {
300+
config.minimumRetryDelay(null);
301+
});
300302

301-
// Then
302-
assertNull(result.getMinimumRetryDelay());
303-
assertSame(config, result, "Should return the same Configuration instance for method chaining");
303+
assertEquals("minimumRetryDelay cannot be null", exception.getMessage());
304304
}
305305

306306
@Test

0 commit comments

Comments
 (0)