HHH-9482 - Avoid automatic timing out when requested timeout is 1 second

Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
Jan Schatteman 2024-02-06 21:03:18 +01:00 committed by Christian Beikov
parent f8c0df8724
commit 30afa87434
1 changed files with 3 additions and 3 deletions

View File

@ -257,11 +257,11 @@ public class JdbcCoordinatorImpl implements JdbcCoordinator {
if ( transactionTimeOutInstant < 0 ) { if ( transactionTimeOutInstant < 0 ) {
return -1; return -1;
} }
final int secondsRemaining = (int) ((transactionTimeOutInstant - System.currentTimeMillis()) / 1000); final long millisecondsRemaining = transactionTimeOutInstant - System.currentTimeMillis();
if ( secondsRemaining <= 0 ) { if ( millisecondsRemaining <= 0L ) {
throw new TransactionException( "transaction timeout expired" ); throw new TransactionException( "transaction timeout expired" );
} }
return secondsRemaining; return Math.max( (int) (millisecondsRemaining / 1000), 1 );
} }
@Override @Override