Skip to content

Conversation

@JunggiKim
Copy link

Fixes #5078

Summary

When retryLimit() is called without explicit retry() configuration, fault-tolerant steps now default to retrying Exception types only, excluding fatal JVM Error types like OutOfMemoryError and StackOverflowError.

Problem

Previously, using retryLimit(N) without retry(...) would retry all Throwable types, including fatal JVM errors that should fail immediately.

Example of problematic code:

builder.faultTolerant()
       .retryLimit(3);  // Would retry OutOfMemoryError 3 times

Solution

Modified ChunkOrientedStepBuilder.build() to default to Set.of(Exception.class) when retryableExceptions is empty, preserving explicit retry() configurations for backward compatibility.

After the fix:

builder.faultTolerant()
       .retryLimit(3);  // Retries Exceptions only, not Errors

Changes

Modified

  • ChunkOrientedStepBuilder.java: Added JavaDoc and default Exception.class logic (+16, -4 lines)

Added

  • ChunkOrientedStepBuilderTests.java: 3 unit tests verifying the fix and backward compatibility

Tests

  • testRetryLimitWithoutRetryDoesNotRetryErrors: Verifies OutOfMemoryError is not retried
  • testRetryLimitWithoutRetryRetriesExceptions: Verifies RuntimeException is retried (no regression)
  • testExplicitRetryConfigurationTakesPrecedence: Verifies explicit retry() still works (backward compatibility)

Backward Compatibility

✅ 100% backward compatible - explicit retry() configurations work exactly as before

When retryLimit() is used without explicit retry() configuration,
the default behavior now retries Exception types only, excluding
Error types like OutOfMemoryError and StackOverflowError.

Resolves spring-projectsgh-5078

Signed-off-by: kjg <kimjg2477@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ChunkOrientedStepBuilder: All Throwables (including Errors) are retried when only retryLimit() is configured without retry()

1 participant