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-1599: CloseablePersistenceManager is no longer needed (Alexander Kolbasov, Reviewed by: Hao Hao)
Date Wed, 25 Jan 2017 19:28:55 GMT
Repository: sentry
Updated Branches:
  refs/heads/sentry-ha-redesign 9652979cf -> 78bd5ded7


SENTRY-1599: CloseablePersistenceManager is no longer needed (Alexander Kolbasov, Reviewed
by: Hao Hao)


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

Branch: refs/heads/sentry-ha-redesign
Commit: 78bd5ded70340d1724469a75e443e4ac9b5f6a67
Parents: 9652979
Author: Alexander Kolbasov <akolb@cloudera.com>
Authored: Mon Jan 23 10:29:10 2017 -0800
Committer: Alexander Kolbasov <akolb@cloudera.com>
Committed: Wed Jan 25 11:26:44 2017 -0800

----------------------------------------------------------------------
 .../service/persistent/TransactionManager.java  | 27 +++-----------------
 1 file changed, 4 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/78bd5ded/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 ec365bf..6428a0c 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
@@ -104,12 +104,11 @@ public class TransactionManager {
    */
   public <T> T executeTransaction(TransactionBlock<T> tb) throws Exception {
     final Timer.Context context = transactionTimer.time();
-    try (CloseablePersistenceManager cpm =
-        new CloseablePersistenceManager(pmf.getPersistenceManager())) {
-      Transaction transaction = cpm.pm.currentTransaction();
+    try (PersistenceManager pm = pmf.getPersistenceManager()) {
+      Transaction transaction = pm.currentTransaction();
       transaction.begin();
       try {
-        T result = tb.execute(cpm.pm);
+        T result = tb.execute(pm);
         transaction.commit();
         return result;
       } catch (Exception e) {
@@ -159,22 +158,4 @@ public class TransactionManager {
     }
     return null;
   }
-
-  /**
-   * CloseablePersistenceManager is a wrapper around PersistenceManager that
-   * implements AutoCloseable interface. It is needed because Apache jdo doesn't
-   * implement AutoCloseable (Datanucleus version does).
-   */
-  private class CloseablePersistenceManager implements AutoCloseable {
-    private final PersistenceManager pm;
-
-    CloseablePersistenceManager(PersistenceManager pm) {
-      this.pm = pm;
-    }
-
-    @Override
-    public void close() throws Exception {
-      pm.close();
-    }
-  }
-}
\ No newline at end of file
+}


Mime
View raw message