HHH-15082 Correctly propagate the original exception when aborting a JDBC batch fails
Not strictly necessary, but it's related to these changes and I think it's a good idea.
This commit is contained in:
parent
8f5c0b7610
commit
5febc70134
|
@ -93,8 +93,13 @@ public abstract class AbstractBatchImpl implements Batch {
|
||||||
return sqlStatementLogger;
|
return sqlStatementLogger;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void abortBatch() {
|
protected void abortBatch(Exception cause) {
|
||||||
jdbcCoordinator.abortBatch();
|
try {
|
||||||
|
jdbcCoordinator.abortBatch();
|
||||||
|
}
|
||||||
|
catch (RuntimeException e) {
|
||||||
|
cause.addSuppressed( e );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -78,12 +78,12 @@ public class BatchingBatch extends AbstractBatchImpl {
|
||||||
currentStatement.addBatch();
|
currentStatement.addBatch();
|
||||||
}
|
}
|
||||||
catch ( SQLException e ) {
|
catch ( SQLException e ) {
|
||||||
abortBatch();
|
abortBatch( e );
|
||||||
LOG.debugf( "SQLException escaped proxy", e );
|
LOG.debugf( "SQLException escaped proxy", e );
|
||||||
throw sqlExceptionHelper().convert( e, "could not perform addBatch", currentStatementSql );
|
throw sqlExceptionHelper().convert( e, "could not perform addBatch", currentStatementSql );
|
||||||
}
|
}
|
||||||
catch (RuntimeException e) {
|
catch (RuntimeException e) {
|
||||||
abortBatch();
|
abortBatch( e );
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
statementPosition++;
|
statementPosition++;
|
||||||
|
@ -130,12 +130,12 @@ public class BatchingBatch extends AbstractBatchImpl {
|
||||||
checkRowCounts( rowCounts, statement, sql );
|
checkRowCounts( rowCounts, statement, sql );
|
||||||
}
|
}
|
||||||
catch ( SQLException e ) {
|
catch ( SQLException e ) {
|
||||||
abortBatch();
|
abortBatch( e );
|
||||||
LOG.unableToExecuteBatch( e, sql );
|
LOG.unableToExecuteBatch( e, sql );
|
||||||
throw sqlExceptionHelper().convert( e, "could not execute batch", sql );
|
throw sqlExceptionHelper().convert( e, "could not execute batch", sql );
|
||||||
}
|
}
|
||||||
catch ( RuntimeException re ) {
|
catch ( RuntimeException re ) {
|
||||||
abortBatch();
|
abortBatch( re );
|
||||||
LOG.unableToExecuteBatch( re, sql );
|
LOG.unableToExecuteBatch( re, sql );
|
||||||
throw re;
|
throw re;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,11 +49,11 @@ public class NonBatchingBatch extends AbstractBatchImpl {
|
||||||
jdbcCoordinator.afterStatementExecution();
|
jdbcCoordinator.afterStatementExecution();
|
||||||
}
|
}
|
||||||
catch ( SQLException e ) {
|
catch ( SQLException e ) {
|
||||||
abortBatch();
|
abortBatch( e );
|
||||||
throw sqlExceptionHelper().convert( e, "could not execute non-batched batch statement", statementSQL );
|
throw sqlExceptionHelper().convert( e, "could not execute non-batched batch statement", statementSQL );
|
||||||
}
|
}
|
||||||
catch (RuntimeException e) {
|
catch (RuntimeException e) {
|
||||||
abortBatch();
|
abortBatch( e );
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue