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-1759: UpdatableCache leaks connections (Alex Kolbasov, reviewed by: Vamsee Yarlagadda, Na Li, Sergio Pena and Kalyan Kalvagadda)
Date Wed, 10 May 2017 16:40:08 GMT
Repository: sentry
Updated Branches:
  refs/heads/master d128f8396 -> 3834e3b15


SENTRY-1759: UpdatableCache leaks connections (Alex Kolbasov, reviewed by: Vamsee Yarlagadda,
Na Li, Sergio Pena and Kalyan Kalvagadda)


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

Branch: refs/heads/master
Commit: 3834e3b15471259081b547b95be5f4f07393dd1f
Parents: d128f83
Author: Alexander Kolbasov <akolb@cloudera.com>
Authored: Wed May 10 09:38:21 2017 -0700
Committer: Alexander Kolbasov <akolb@cloudera.com>
Committed: Wed May 10 09:38:21 2017 -0700

----------------------------------------------------------------------
 .../provider/db/generic/UpdatableCache.java     | 35 ++++++++++++--------
 1 file changed, 21 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/3834e3b1/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/UpdatableCache.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/UpdatableCache.java
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/UpdatableCache.java
index f272630..41708c3 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/UpdatableCache.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/generic/UpdatableCache.java
@@ -94,22 +94,29 @@ class UpdatableCache implements TableCache {
     String requestor;
     requestor = UserGroupInformation.getLoginUser().getShortUserName();
 
-    final SentryGenericServiceClient client = getClient();
-    final Set<TSentryRole> tSentryRoles = client.listAllRoles(requestor, componentType);
-
-    for (TSentryRole tSentryRole : tSentryRoles) {
-      final String roleName = tSentryRole.getRoleName();
-      final Set<TSentryPrivilege> tSentryPrivileges = client.listPrivilegesByRoleName(requestor,
roleName, componentType, serviceName);
-      for (String group : tSentryRole.getGroups()) {
-        Set<String> currentPrivileges = tempCache.get(group, roleName);
-        if (currentPrivileges == null) {
-          currentPrivileges = new HashSet<>();
-          tempCache.put(group, roleName, currentPrivileges);
-        }
-        for (TSentryPrivilege tSentryPrivilege : tSentryPrivileges) {
-          currentPrivileges.add(tSentryPrivilegeConverter.toString(tSentryPrivilege));
+    SentryGenericServiceClient client = null;
+    try {
+      client = getClient();
+      final Set<TSentryRole> tSentryRoles = client.listAllRoles(requestor, componentType);
+
+      for (TSentryRole tSentryRole : tSentryRoles) {
+        final String roleName = tSentryRole.getRoleName();
+        final Set<TSentryPrivilege> tSentryPrivileges = client.listPrivilegesByRoleName(requestor,
roleName, componentType, serviceName);
+        for (String group : tSentryRole.getGroups()) {
+          Set<String> currentPrivileges = tempCache.get(group, roleName);
+          if (currentPrivileges == null) {
+            currentPrivileges = new HashSet<>();
+            tempCache.put(group, roleName, currentPrivileges);
+          }
+          for (TSentryPrivilege tSentryPrivilege : tSentryPrivileges) {
+            currentPrivileges.add(tSentryPrivilegeConverter.toString(tSentryPrivilege));
+          }
         }
       }
+    } finally {
+      if (client != null) {
+        client.close();
+      }
     }
     return tempCache;
   }


Mime
View raw message