bito-code-review[bot] commented on PR #15744:
URL: https://github.com/apache/grails-core/pull/15744#issuecomment-4843220286
<!-- Bito Reply -->
The implementation of `MongoTransaction` already includes explicit error
handling for transaction operations. Specifically, `commit()` uses a
`try-finally` block where a failed commit or flush triggers an explicit
`abortTransaction()` call, and `rollback()` also calls `abortTransaction()`
within a `try-finally` block to ensure the session is closed. These mechanisms
prevent silent failures by ensuring that server-side transactions are aborted
and the GORM session is cleared if an error occurs.
**grails-data-mongodb/core/src/main/groovy/org/grails/datastore/mapping/mongo/MongoTransaction.java**
```
try {
session.flush();
commitWithRetry();
committed = true;
} finally {
if (!committed) {
if (clientSession.hasActiveTransaction()) {
try {
clientSession.abortTransaction();
}
catch (RuntimeException e) {
LOG.debug("Error aborting transaction after failed
commit: {}", e.getMessage(), e);
}
}
// ...
}
close();
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]