sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject sentry git commit: SENTRY-1599: CloseablePersistenceManager is no longer needed (Alexander Kolbasov, Reviewed by: Hao Hao)
Date Fri, 20 Jan 2017 19:39:16 GMT
Repository: sentry
Updated Branches:
  refs/heads/master d44e67027 -> 963d5e643


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

Change-Id: Iab72b0af21cd8280c6c3a24e101b25a22d0d3f00


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

Branch: refs/heads/master
Commit: 963d5e643e8b575ff22cce11cd0659f4e4774334
Parents: d44e670
Author: hahao <hao.hao@cloudera.com>
Authored: Fri Jan 20 11:36:28 2017 -0800
Committer: hahao <hao.hao@cloudera.com>
Committed: Fri Jan 20 11:36:28 2017 -0800

----------------------------------------------------------------------
 .../service/persistent/TransactionManager.java  | 25 +++-----------------
 1 file changed, 3 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/963d5e64/sentry-service/sentry-service-server/src/main/java/org/apache/sentry/provider/db/service/persistent/TransactionManager.java
----------------------------------------------------------------------
diff --git a/sentry-service/sentry-service-server/src/main/java/org/apache/sentry/provider/db/service/persistent/TransactionManager.java
b/sentry-service/sentry-service-server/src/main/java/org/apache/sentry/provider/db/service/persistent/TransactionManager.java
index ee13f9f..6428a0c 100644
--- a/sentry-service/sentry-service-server/src/main/java/org/apache/sentry/provider/db/service/persistent/TransactionManager.java
+++ b/sentry-service/sentry-service-server/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();
-    }
-  }
 }


Mime
View raw message