@@ -182,7 +182,7 @@ else if ( state.value == State.ROLLED_BACK )
182182 {
183183 return resultCursors .retrieveNotConsumedError ()
184184 .thenCompose ( error -> doCommitAsync ( error ).handle ( handleCommitOrRollback ( error ) ) )
185- .whenComplete ( ( ignore , error ) -> handleTransactionCompletion ( State . COMMITTED , error ) );
185+ .whenComplete ( ( ignore , error ) -> handleTransactionCompletion ( true , error ) );
186186 }
187187 }
188188
@@ -200,7 +200,7 @@ else if ( state.value == State.ROLLED_BACK )
200200 {
201201 return resultCursors .retrieveNotConsumedError ()
202202 .thenCompose ( error -> doRollbackAsync ().handle ( handleCommitOrRollback ( error ) ) )
203- .whenComplete ( ( ignore , error ) -> handleTransactionCompletion ( State . ROLLED_BACK , error ) );
203+ .whenComplete ( ( ignore , error ) -> handleTransactionCompletion ( false , error ) );
204204 }
205205 }
206206
@@ -287,16 +287,24 @@ private static BiFunction<Void,Throwable,Void> handleCommitOrRollback( Throwable
287287 };
288288 }
289289
290- private void handleTransactionCompletion ( State onSuccessState , Throwable throwable )
290+ private void handleTransactionCompletion ( boolean commitOnSuccess , Throwable throwable )
291291 {
292+ if ( commitOnSuccess && throwable == null )
293+ {
294+ state = StateHolder .of ( State .COMMITTED );
295+ }
296+ else
297+ {
298+ state = StateHolder .of ( State .ROLLED_BACK );
299+ }
300+
292301 if ( throwable instanceof AuthorizationExpiredException )
293302 {
294- markTerminated ( throwable );
295303 connection .terminateAndRelease ( AuthorizationExpiredException .DESCRIPTION );
296- return ;
297304 }
298-
299- state = StateHolder .of ( onSuccessState );
300- connection .release (); // release in background
305+ else
306+ {
307+ connection .release (); // release in background
308+ }
301309 }
302310}
0 commit comments