Skip to content

Commit 8ec2743

Browse files
remeiosimonbasle
authored andcommitted
Fix transaction definition setTimeout error message since zero is valid
This commit rephrases the `DefaultTransactionDefinition#setTimeout` exception message to better reflect the fact that 0 is a valid input value. Even though this often leads to a transaction immediately timing out after opening, there is one notable case where this has another meaningful effect: in Jakarta transactions (`UserTransaction`), when passing 0 "the transaction service restores the default value". Closes gh-32635
1 parent bf32785 commit 8ec2743

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

spring-tx/src/main/java/org/springframework/transaction/support/DefaultTransactionDefinition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public final int getIsolationLevel() {
227227
*/
228228
public final void setTimeout(int timeout) {
229229
if (timeout < TIMEOUT_DEFAULT) {
230-
throw new IllegalArgumentException("Timeout must be a positive integer or TIMEOUT_DEFAULT");
230+
throw new IllegalArgumentException("Timeout must be a non-negative integer or TIMEOUT_DEFAULT");
231231
}
232232
this.timeout = timeout;
233233
}

0 commit comments

Comments
 (0)