Skip to content

Commit 6315a03

Browse files
committed
[#2926] Minor refactoring in MutinySessionImpl
* Rename variable "rollback" to "markedForRollback" * Change formattation
1 parent 2e6e057 commit 6315a03

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/mutiny/impl/MutinySessionImpl.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ public Mutiny.Transaction currentTransaction() {
488488
}
489489

490490
private class Transaction<T> implements Mutiny.Transaction {
491-
boolean rollback;
491+
boolean markedForRollback;
492492

493493
Uni<T> execute(Function<Mutiny.Transaction, Uni<T>> work) {
494494
currentTransaction = this;
@@ -504,13 +504,16 @@ Uni<T> executeInTransaction(Function<Mutiny.Transaction, Uni<T>> work) {
504504
return Uni.createFrom()
505505
.deferred( () -> work.apply( this ) )
506506
// only flush() if the work completed with no exception
507-
.call( this::flush ).call( this::beforeCompletion )
507+
.call( this::flush )
508+
.call( this::beforeCompletion )
508509
// in the case of an exception or cancellation
509510
// we need to roll back the transaction
510-
.onFailure().call( this::rollback ).onCancellation().call( this::rollback )
511+
.onFailure().call( this::rollback )
512+
.onCancellation().call( this::rollback )
511513
// finally, when there was no exception,
512514
// commit or rollback the transaction
513-
.call( () -> rollback ? rollback() : commit() ).call( this::afterCompletion );
515+
.call( () -> markedForRollback ? rollback() : commit() )
516+
.call( this::afterCompletion );
514517
}
515518

516519
Uni<Void> flush() {
@@ -534,17 +537,17 @@ private Uni<Void> beforeCompletion() {
534537
}
535538

536539
private Uni<Void> afterCompletion() {
537-
return Uni.createFrom().completionStage( delegate.getReactiveActionQueue().afterTransactionCompletion( !rollback ) );
540+
return Uni.createFrom().completionStage( delegate.getReactiveActionQueue().afterTransactionCompletion( !markedForRollback ) );
538541
}
539542

540543
@Override
541544
public void markForRollback() {
542-
rollback = true;
545+
markedForRollback = true;
543546
}
544547

545548
@Override
546549
public boolean isMarkedForRollback() {
547-
return rollback;
550+
return markedForRollback;
548551
}
549552
}
550553

0 commit comments

Comments
 (0)