Github user jburwell commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/768#discussion_r42446276
  
    --- Diff: framework/db/src/com/cloud/utils/db/Transaction.java ---
    @@ -59,4 +59,30 @@ public T doInTransaction(TransactionStatus status) 
throws RuntimeException {
             });
         }
     
    +    @SuppressWarnings("deprecation")
    +    public static <T, E extends Throwable> T execute(final short 
databaseId, TransactionCallbackWithException<T, E> callback) throws E {
    +        String name = "tx-" + counter.incrementAndGet();
    +        TransactionLegacy currentTxn = TransactionLegacy.currentTxn(false);
    +        short outer_txn_databaseId = (currentTxn != null ? 
currentTxn.getDatabaseId() : databaseId);
    +        TransactionLegacy txn = TransactionLegacy.open(name, databaseId, 
true);
    +        try {
    --- End diff --
    
    Lines 67 and 68 can be combined into a try with resources as follows:
    
    ```
            try (final TransactionLegacy txn = TransactionLegacy.open(name, 
databaseId, false)) {
    ```
    
    This construct also removes the need for the ```txn.close()``` on line 74.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to