Skip to content

Commit cdf9608

Browse files
committed
IGNITE-27947 Update CLientLazyTransaction error handling logic.
1 parent 49c0fc2 commit cdf9608

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

modules/client/src/main/java/org/apache/ignite/internal/client/tx/ClientLazyTransaction.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import static org.apache.ignite.internal.client.tx.ClientTransactions.USE_CONFIGURED_TIMEOUT_DEFAULT;
2121
import static org.apache.ignite.internal.util.CompletableFutures.nullCompletedFuture;
22-
import static org.apache.ignite.internal.util.ExceptionUtils.sneakyThrow;
2322

2423
import java.util.EnumSet;
2524
import java.util.concurrent.CompletableFuture;
@@ -108,24 +107,23 @@ public CompletableFuture<Void> rollbackAsync() {
108107
}
109108

110109
// If the transaction is not started. Issue the rollback and wait for the server response.
111-
CompletableFuture<Void> ret;
112110
if (!tx0.isDone() && cancelled.compareAndSet(false, true)) {
113-
ret = requestInfoFuture
111+
return requestInfoFuture
114112
.thenCompose(reqInfo ->
115113
reqInfo.ch.serviceAsync(ClientOp.TX_ROLLBACK, w -> w.out().packLong(-reqInfo.firstReqId), r -> null)
116114
)
117115
.handle((res, e) -> {
118-
if (e != null) {
119-
throw sneakyThrow(ViewUtils.ensurePublicException(e));
116+
// If ok, we don't need to wait for the response. If error, let's block.
117+
if (e == null) {
118+
return nullCompletedFuture();
119+
} else {
120+
return tx0.thenCompose(ClientTransaction::rollbackAsync);
120121
}
121-
122-
return null;
123-
});
122+
})
123+
.thenCompose(f -> (CompletableFuture<Void>) f);
124124
} else {
125-
ret = nullCompletedFuture();
125+
return tx0.thenCompose(ClientTransaction::rollbackAsync);
126126
}
127-
128-
return ret.thenCompose(none -> tx0.thenCompose(ClientTransaction::rollbackAsync));
129127
}
130128

131129
@Override

0 commit comments

Comments
 (0)