Skip to content

Commit b36e61c

Browse files
committed
chore: Remove unnecessary transaction null check
1 parent c82e1d8 commit b36e61c

File tree

1 file changed

+3
-4
lines changed
  • java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore

1 file changed

+3
-4
lines changed

java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreImpl.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public T call() throws DatastoreException {
216216
// or from `transaction.commit()`. If there is an exception thrown from either call site,
217217
// then the transaction is still active. Check if it is still active (e.g. not commited)
218218
// and roll back the transaction.
219-
if (transaction != null && transaction.isActive()) {
219+
if (transaction.isActive()) {
220220
transaction.rollback();
221221
}
222222
throw DatastoreException.propagateUserException(ex);
@@ -225,11 +225,10 @@ public T call() throws DatastoreException {
225225
// If the transaction is active, then commit the rollback. If it was already successfully
226226
// rolled back, the transaction is inactive (prevents rolling back an already rolled back
227227
// transaction).
228-
if (transaction != null && transaction.isActive()) {
228+
if (transaction.isActive()) {
229229
transaction.rollback();
230230
}
231-
if (transaction != null
232-
&& options != null
231+
if (options != null
233232
&& options.getModeCase().equals(TransactionOptions.ModeCase.READ_WRITE)) {
234233
setPrevTransactionId(transaction.getTransactionId());
235234
}

0 commit comments

Comments
 (0)