sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ak...@apache.org
Subject sentry git commit: SENTRY-1691: TransactionManager should use try-with-resource for timers (Sergio Pena, reviewed by: Alex Kolbasov and Na Li)
Date Mon, 24 Apr 2017 16:14:46 GMT
Repository: sentry
Updated Branches:
  refs/heads/sentry-ha-redesign a5e772b51 -> 618260530


SENTRY-1691: TransactionManager should use try-with-resource for timers (Sergio Pena, reviewed
by: Alex Kolbasov and Na Li)


Project: http://git-wip-us.apache.org/repos/asf/sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/sentry/commit/61826053
Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/61826053
Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/61826053

Branch: refs/heads/sentry-ha-redesign
Commit: 618260530e190d01dd3c1412b81703e514725e4f
Parents: a5e772b
Author: Alexander Kolbasov <akolb@cloudera.com>
Authored: Mon Apr 24 09:14:29 2017 -0700
Committer: Alexander Kolbasov <akolb@cloudera.com>
Committed: Mon Apr 24 09:14:29 2017 -0700

----------------------------------------------------------------------
 .../db/service/persistent/TransactionManager.java         | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/61826053/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/TransactionManager.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/TransactionManager.java
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/TransactionManager.java
index fb7c40a..d11d34f 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/TransactionManager.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/TransactionManager.java
@@ -106,8 +106,8 @@ public class TransactionManager {
    * @return Object with the result of tb.execute()
    */
   public <T> T executeTransaction(TransactionBlock<T> tb) throws Exception {
-    final Timer.Context context = transactionTimer.time();
-    try (PersistenceManager pm = pmf.getPersistenceManager()) {
+    try (Timer.Context context = transactionTimer.time();
+         PersistenceManager pm = pmf.getPersistenceManager()) {
       Transaction transaction = pm.currentTransaction();
       transaction.begin();
       try {
@@ -123,7 +123,6 @@ public class TransactionManager {
         // Re-throw the exception
         throw e;
       } finally {
-        context.stop();
         if (transaction.isActive()) {
           transaction.rollback();
         }
@@ -141,8 +140,8 @@ public class TransactionManager {
    * @return the result of the last result of tb.execute()
    */
   public <T> T executeTransaction(Iterable<TransactionBlock<T>> tbs) throws
Exception {
-    final Timer.Context context = transactionTimer.time();
-    try (PersistenceManager pm = pmf.getPersistenceManager()) {
+    try (Timer.Context context = transactionTimer.time();
+         PersistenceManager pm = pmf.getPersistenceManager()) {
       Transaction transaction = pm.currentTransaction();
       transaction.begin();
       try {
@@ -161,7 +160,6 @@ public class TransactionManager {
         // Re-throw the exception
         throw e;
       } finally {
-        context.stop();
         if (transaction.isActive()) {
           transaction.rollback();
         }


Mime
View raw message