ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject ranger git commit: RANGER-1561:Good coding practice in Ranger recommended by static code analysis
Date Mon, 08 May 2017 02:41:33 GMT
Repository: ranger
Updated Branches:
  refs/heads/master 87bc2e786 -> c213c9587


RANGER-1561:Good coding practice in Ranger recommended by static code analysis

Signed-off-by: rmani <rmani@hortonworks.com>


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

Branch: refs/heads/master
Commit: c213c9587dd6c2c8403eab30470575a7e3bbdb07
Parents: 87bc2e7
Author: rmani <rmani@hortonworks.com>
Authored: Sun May 7 15:13:18 2017 -0700
Committer: rmani <rmani@hortonworks.com>
Committed: Sun May 7 19:41:22 2017 -0700

----------------------------------------------------------------------
 .../services/hive/HIVERangerAuthorizerTest.java      | 15 +++++++++------
 .../patch/PatchForHiveServiceDefUpdate_J10007.java   |  2 +-
 2 files changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/c213c958/hive-agent/src/test/java/org/apache/ranger/services/hive/HIVERangerAuthorizerTest.java
----------------------------------------------------------------------
diff --git a/hive-agent/src/test/java/org/apache/ranger/services/hive/HIVERangerAuthorizerTest.java
b/hive-agent/src/test/java/org/apache/ranger/services/hive/HIVERangerAuthorizerTest.java
index c4c2a2a..011d2c3 100644
--- a/hive-agent/src/test/java/org/apache/ranger/services/hive/HIVERangerAuthorizerTest.java
+++ b/hive-agent/src/test/java/org/apache/ranger/services/hive/HIVERangerAuthorizerTest.java
@@ -677,18 +677,21 @@ public class HIVERangerAuthorizerTest {
     // S3 location URI authorization (by the policy - user bob)
     @Test
     public void testS3URIAuthorization() throws Exception {
-
         String url = "jdbc:hive2://localhost:" + port + "/rangerauthz";
-        Connection connection = DriverManager.getConnection(url, "bob", "bob");
-        Statement statement = connection.createStatement();
+        Connection connection = null;
+        Statement statement   = null;
         try {
+            connection = DriverManager.getConnection(url, "bob", "bob");
+            statement = connection.createStatement();
             statement.executeQuery("create table if not exists words (word STRING, count
INT) row format delimited fields terminated by '\t' stored as textfile LOCATION 's3a://test/data'");
             Assert.fail("Failure expected on an unauthorized call");
-        } catch ( SQLException sqe) {
             //expected we don't get any resultset here
+        } catch(SQLException ex){
+                //expected
+        } finally {
+            statement.close();
+            connection.close();
         }
-        statement.close();
-        connection.close();
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ranger/blob/c213c958/security-admin/src/main/java/org/apache/ranger/patch/PatchForHiveServiceDefUpdate_J10007.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/patch/PatchForHiveServiceDefUpdate_J10007.java
b/security-admin/src/main/java/org/apache/ranger/patch/PatchForHiveServiceDefUpdate_J10007.java
index a886945..e0c6a65 100644
--- a/security-admin/src/main/java/org/apache/ranger/patch/PatchForHiveServiceDefUpdate_J10007.java
+++ b/security-admin/src/main/java/org/apache/ranger/patch/PatchForHiveServiceDefUpdate_J10007.java
@@ -143,7 +143,7 @@ public class PatchForHiveServiceDefUpdate_J10007 extends BaseLoader {
 					ret = svcStore.updateServiceDef(dbHiveServiceDef);
 					if(ret==null){
 						logger.error("Error while updating "+SERVICEDBSTORE_SERVICEDEFBYNAME_HIVE_NAME+"service-def");
-						System.exit(1);
+						throw new RuntimeException("Error while updating "+SERVICEDBSTORE_SERVICEDEFBYNAME_HIVE_NAME+"service-def");
 					}
 				}
 			}


Mime
View raw message