Return-Path: X-Original-To: apmail-ranger-commits-archive@www.apache.org Delivered-To: apmail-ranger-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C457A18714 for ; Thu, 24 Sep 2015 20:44:51 +0000 (UTC) Received: (qmail 60843 invoked by uid 500); 24 Sep 2015 20:44:51 -0000 Delivered-To: apmail-ranger-commits-archive@ranger.apache.org Received: (qmail 60815 invoked by uid 500); 24 Sep 2015 20:44:51 -0000 Mailing-List: contact commits-help@ranger.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ranger.incubator.apache.org Delivered-To: mailing list commits@ranger.incubator.apache.org Received: (qmail 60806 invoked by uid 99); 24 Sep 2015 20:44:51 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Sep 2015 20:44:51 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 3B0441A0778 for ; Thu, 24 Sep 2015 20:44:51 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.781 X-Spam-Level: * X-Spam-Status: No, score=1.781 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id zxXdY5TFYD1S for ; Thu, 24 Sep 2015 20:44:50 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with SMTP id 02C0C2308B for ; Thu, 24 Sep 2015 20:44:49 +0000 (UTC) Received: (qmail 60797 invoked by uid 99); 24 Sep 2015 20:44:49 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Sep 2015 20:44:49 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7C4F2E08E7; Thu, 24 Sep 2015 20:44:49 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: madhan@apache.org To: commits@ranger.incubator.apache.org Message-Id: <63f5c10f38c848c698fddf742afbc643@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-ranger git commit: RANGER-661: fixed policy-download to return error, instead of empty policy-list, on failure in retrieving policies from DB Date: Thu, 24 Sep 2015 20:44:49 +0000 (UTC) Repository: incubator-ranger Updated Branches: refs/heads/master baf0ddd6f -> 5b371c7a6 RANGER-661: fixed policy-download to return error, instead of empty policy-list, on failure in retrieving policies from DB Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/5b371c7a Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/5b371c7a Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/5b371c7a Branch: refs/heads/master Commit: 5b371c7a6666bf1504b84ce59caaaa44d49e46e6 Parents: baf0ddd Author: Madhan Neethiraj Authored: Thu Sep 24 00:20:01 2015 -0700 Committer: Madhan Neethiraj Committed: Thu Sep 24 13:44:00 2015 -0700 ---------------------------------------------------------------------- .../org/apache/ranger/biz/ServiceDBStore.java | 32 ++++++-------------- .../apache/ranger/biz/TestServiceDBStore.java | 6 ++-- 2 files changed, 13 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/5b371c7a/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java b/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java index d62c645..a5ac557 100644 --- a/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java +++ b/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java @@ -1582,19 +1582,13 @@ public class ServiceDBStore implements ServiceStore { LOG.debug("==> ServiceDBStore.getServicePolicies(" + serviceName + ")"); } - List ret = new ArrayList(); - - try { - if(filter == null) { - filter = new SearchFilter(); - } + if(filter == null) { + filter = new SearchFilter(); + } - filter.setParam(SearchFilter.SERVICE_NAME, serviceName); + filter.setParam(SearchFilter.SERVICE_NAME, serviceName); - ret = getPolicies(filter); - } catch(Exception excp) { - LOG.error("ServiceDBStore.getServicePolicies(" + serviceName + "): failed to read policies", excp); - } + List ret = getPolicies(filter); if(LOG.isDebugEnabled()) { LOG.debug("<== ServiceDBStore.getServicePolicies(" + serviceName + "): count=" + ((ret == null) ? 0 : ret.size())); @@ -1608,19 +1602,13 @@ public class ServiceDBStore implements ServiceStore { LOG.debug("==> ServiceDBStore.getPaginatedServicePolicies(" + serviceName + ")"); } - RangerPolicyList ret = null; - - try { - if (filter == null) { - filter = new SearchFilter(); - } + if (filter == null) { + filter = new SearchFilter(); + } - filter.setParam(SearchFilter.SERVICE_NAME, serviceName); + filter.setParam(SearchFilter.SERVICE_NAME, serviceName); - ret = getPaginatedPolicies(filter); - } catch (Exception excp) { - LOG.error("ServiceDBStore.getPaginatedServicePolicies(" + serviceName + "): failed to read policies", excp); - } + RangerPolicyList ret = getPaginatedPolicies(filter); if (LOG.isDebugEnabled()) { LOG.debug("<== ServiceDBStore.getPaginatedServicePolicies(" + serviceName + "): count=" http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/5b371c7a/security-admin/src/test/java/org/apache/ranger/biz/TestServiceDBStore.java ---------------------------------------------------------------------- diff --git a/security-admin/src/test/java/org/apache/ranger/biz/TestServiceDBStore.java b/security-admin/src/test/java/org/apache/ranger/biz/TestServiceDBStore.java index 70e89a3..bd4e9d4 100644 --- a/security-admin/src/test/java/org/apache/ranger/biz/TestServiceDBStore.java +++ b/security-admin/src/test/java/org/apache/ranger/biz/TestServiceDBStore.java @@ -2430,9 +2430,9 @@ public class TestServiceDBStore { Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao); Mockito.when(xServiceDao.getById(Id)).thenReturn(xService); + thrown.expect(Exception.class); List dbRangerPolicy = serviceDBStore.getServicePolicies( Id, filter); - Assert.assertNotNull(dbRangerPolicy); Mockito.verify(daoManager).getXXService(); } @@ -2533,9 +2533,9 @@ public class TestServiceDBStore { Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao); Mockito.when(xServiceDao.getById(Id)).thenReturn(xService); + thrown.expect(Exception.class); RangerPolicyList dbRangerPolicyList = serviceDBStore .getPaginatedServicePolicies(rangerService.getId(), filter); - Assert.assertNull(dbRangerPolicyList); Mockito.verify(daoManager).getXXService(); } @@ -2602,4 +2602,4 @@ public class TestServiceDBStore { Assert.assertNotNull(policyList); Mockito.verify(daoManager).getXXPolicy(); } -} \ No newline at end of file +}