Skip to content

Commit 94a79db

Browse files
stIncMalenhachicha
authored andcommitted
Use OperationHelper.unwrap to get to the exception that carries labels
1 parent 60acf51 commit 94a79db

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

driver-sync/src/main/com/mongodb/client/internal/ClientSessionImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.mongodb.internal.observability.micrometer.TransactionSpan;
3333
import com.mongodb.internal.operation.AbortTransactionOperation;
3434
import com.mongodb.internal.operation.CommitTransactionOperation;
35+
import com.mongodb.internal.operation.OperationHelper;
3536
import com.mongodb.internal.operation.ReadOperation;
3637
import com.mongodb.internal.operation.WriteConcernHelper;
3738
import com.mongodb.internal.operation.WriteOperation;
@@ -294,13 +295,14 @@ public <T> T withTransaction(final TransactionBody<T> transactionBody, final Tra
294295
abortIfInTransaction();
295296
if (e instanceof MongoException) {
296297
MongoException mongoException = (MongoException) e;
297-
if (mongoException.hasErrorLabel(TRANSIENT_TRANSACTION_ERROR_LABEL)) {
298+
MongoException labelCarryingException = OperationHelper.unwrap(mongoException);
299+
if (labelCarryingException.hasErrorLabel(TRANSIENT_TRANSACTION_ERROR_LABEL)) {
298300
if (transactionSpan != null) {
299301
transactionSpan.spanFinalizing(false);
300302
}
301303
lastError = mongoException;
302304
continue;
303-
} else if (mongoException.hasErrorLabel(UNKNOWN_TRANSACTION_COMMIT_RESULT_LABEL)) {
305+
} else if (labelCarryingException.hasErrorLabel(UNKNOWN_TRANSACTION_COMMIT_RESULT_LABEL)) {
304306
throw e;
305307
} else {
306308
throw withTransactionTimeoutExpired.getAsBoolean()

0 commit comments

Comments
 (0)