@@ -60,7 +60,7 @@ class MongoStatementIntegrationTests {
6060 private Session session ;
6161
6262 @ Parameter
63- boolean autoCommit ;
63+ private boolean autoCommit ;
6464
6565 @ BeforeAll
6666 static void beforeAll () {
@@ -282,15 +282,20 @@ static void insertTestData(Session session, String insertMql) {
282282 }
283283
284284 private void doWorkAwareOfAutoCommit (Work work ) {
285- session . doWork ( connection -> doAwareOfAutoCommit ( connection , () -> work . execute ( connection )) );
285+ doWorkWithSpecifiedAutoCommit ( autoCommit , session , work );
286286 }
287287
288- void doAwareOfAutoCommit (Connection connection , SqlExecutable work ) throws SQLException {
289- doWithSpecifiedAutoCommit (
290- autoCommit , connection , autoCommit ? work : () -> doAndTerminateTransaction (connection , work ));
288+ static void doWorkWithSpecifiedAutoCommit (boolean autoCommit , Session session , Work work ) {
289+ session .doWork (connection -> {
290+ SqlExecutable executable = () -> work .execute (connection );
291+ doWithSpecifiedAutoCommit (
292+ autoCommit ,
293+ connection ,
294+ autoCommit ? executable : () -> doAndTerminateTransaction (connection , executable ));
295+ });
291296 }
292297
293- static void doWithSpecifiedAutoCommit (boolean autoCommit , Connection connection , SqlExecutable work )
298+ private static void doWithSpecifiedAutoCommit (boolean autoCommit , Connection connection , SqlExecutable work )
294299 throws SQLException {
295300 var originalAutoCommit = connection .getAutoCommit ();
296301 connection .setAutoCommit (autoCommit );
@@ -301,7 +306,8 @@ static void doWithSpecifiedAutoCommit(boolean autoCommit, Connection connection,
301306 }
302307 }
303308
304- static void doAndTerminateTransaction (Connection connectionNoAutoCommit , SqlExecutable work ) throws SQLException {
309+ private static void doAndTerminateTransaction (Connection connectionNoAutoCommit , SqlExecutable work )
310+ throws SQLException {
305311 Throwable primaryException = null ;
306312 try {
307313 work .execute ();
@@ -320,7 +326,7 @@ static void doAndTerminateTransaction(Connection connectionNoAutoCommit, SqlExec
320326 }
321327 }
322328
323- interface SqlExecutable {
329+ private interface SqlExecutable {
324330 void execute () throws SQLException ;
325331 }
326332}
0 commit comments