Skip to content

Fail TaskletStep on checked exceptions in non-rollback mode#5316

Open
answndud wants to merge 1 commit intospring-projects:mainfrom
answndud:fix/tasklet-non-tx-repeat-5292
Open

Fail TaskletStep on checked exceptions in non-rollback mode#5316
answndud wants to merge 1 commit intospring-projects:mainfrom
answndud:fix/tasklet-non-tx-repeat-5292

Conversation

@answndud
Copy link

@answndud answndud commented Mar 4, 2026

Summary

  • propagate checked exceptions from Tasklet.execute even when transactionAttribute.rollbackOn(e) returns false
  • only mark rollback metadata (ROLLBACK_EXCEPTION_KEY and rollback count) when rollback is actually configured for the exception
  • add a regression test for PROPAGATION_NOT_SUPPORTED to ensure a checked exception fails the step instead of being silently retried

Why

With TaskletStep and a transaction attribute like PROPAGATION_NOT_SUPPORTED, a checked exception can be swallowed when rollback is disabled for that exception type. This causes the step loop to continue and re-execute the tasklet instead of failing.

Closes #5292

Testing

  • Attempted locally: ./mvnw -Dmaven.user.home=/tmp/m2 -pl spring-batch-core -Dtest=org.springframework.batch.core.step.item.TaskletStepExceptionTests test
  • Local build is blocked by Error Prone/NullAway JSpecify requirement (JDK 22+).

Do not swallow checked exceptions when rollbackOn returns false. Add a regression test for PROPAGATION_NOT_SUPPORTED to ensure the step fails instead of re-executing indefinitely.

Signed-off-by: MJY <jmoon0227@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.

TaskletStep with PROPAGATION_NOT_SUPPORTED keeps re-executing on checked exception

1 participant