ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject incubator-ranger git commit: RANGER-1209: Good coding practices as recommended by static code analysis
Date Mon, 07 Nov 2016 05:22:53 GMT
Repository: incubator-ranger
Updated Branches:
  refs/heads/master ad0fe4b89 -> 5fe203f59


RANGER-1209: Good coding practices as recommended by static code analysis

Signed-off-by: Madhan Neethiraj <madhan@apache.org>


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

Branch: refs/heads/master
Commit: 5fe203f59330f66cd14fa916b9c1a6ebdb9b854d
Parents: ad0fe4b
Author: Abhay Kulkarni <akulkarni@hortonworks.com>
Authored: Sun Nov 6 18:38:59 2016 -0800
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Sun Nov 6 21:05:45 2016 -0800

----------------------------------------------------------------------
 .../java/org/apache/ranger/biz/AssetMgr.java    | 30 ++++++++++----------
 .../org/apache/ranger/entity/XXPluginInfo.java  |  2 --
 2 files changed, 15 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/5fe203f5/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java b/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java
index 3df1aba..479099d 100644
--- a/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java
+++ b/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java
@@ -214,7 +214,7 @@ public class AssetMgr extends AssetMgrBase {
 		if (epoch != null && !epoch.trim().isEmpty() && !epoch.equalsIgnoreCase("null"))
{
 			policyExportAudit.setRequestedEpoch(Long.parseLong(epoch));
 		} else {
-			policyExportAudit.setRequestedEpoch(0l);
+			policyExportAudit.setRequestedEpoch(0L);
 		}
 
 		if (!httpEnabled) {
@@ -281,7 +281,7 @@ public class AssetMgr extends AssetMgrBase {
 		}
 
 		if (policyCount == null) {
-			policyCount = 0l;
+			policyCount = 0L;
 		}
 
 		if (commonName != null) {
@@ -707,7 +707,7 @@ public class AssetMgr extends AssetMgrBase {
 		createOrUpdatePluginInfo(pluginSvcVersionInfo, httpCode);
 	}
 
-	void createOrUpdatePluginInfo(final RangerPluginInfo pluginInfo, final int httpCode) {
+	private void createOrUpdatePluginInfo(final RangerPluginInfo pluginInfo, final int httpCode)
{
 		if (logger.isDebugEnabled()) {
 			logger.debug("==> createOrUpdatePluginInfo(pluginInfo=" + pluginInfo + ", httpCode="
+ httpCode + ")");
 		}
@@ -732,7 +732,7 @@ public class AssetMgr extends AssetMgrBase {
 
 	}
 
-	XXPluginInfo doCreateOrUpdateXXPluginInfo(RangerPluginInfo pluginInfo) {
+	private XXPluginInfo doCreateOrUpdateXXPluginInfo(RangerPluginInfo pluginInfo) {
 		XXPluginInfo ret = null;
 
 		if (StringUtils.isNotBlank(pluginInfo.getServiceName())) {
@@ -746,7 +746,7 @@ public class AssetMgr extends AssetMgrBase {
 					pluginInfo.setPolicyDownloadTime(pluginInfo.getPolicyActivationTime());
 				}
 			} else {
-				if (pluginInfo.getTagDownloadedVersion().equals(pluginInfo.getTagActiveVersion())) {
+				if (pluginInfo.getTagDownloadedVersion() != null && pluginInfo.getTagDownloadedVersion().equals(pluginInfo.getTagActiveVersion()))
{
 					// This is our best guess of when tags may have been downloaded
 					pluginInfo.setTagDownloadTime(pluginInfo.getTagActivationTime());
 				}
@@ -776,16 +776,16 @@ public class AssetMgr extends AssetMgrBase {
 						dbObj.setPolicyDownloadTime(pluginInfo.getPolicyDownloadTime());
 						needsUpdating = true;
 					}
-					long lastKnownPolicyVersion = pluginInfo.getPolicyActiveVersion();
-					long lastPolicyActivationTime = pluginInfo.getPolicyActivationTime();
+					Long lastKnownPolicyVersion = pluginInfo.getPolicyActiveVersion();
+					Long lastPolicyActivationTime = pluginInfo.getPolicyActivationTime();
 
-					if (lastKnownPolicyVersion > 0 && (dbObj.getPolicyActiveVersion() == null
|| !dbObj.getPolicyActiveVersion().equals(lastKnownPolicyVersion))) {
+					if (lastKnownPolicyVersion != null && lastKnownPolicyVersion > 0 &&
(dbObj.getPolicyActiveVersion() == null || !dbObj.getPolicyActiveVersion().equals(lastKnownPolicyVersion)))
{
 						dbObj.setPolicyActiveVersion(lastKnownPolicyVersion);
-						if (lastPolicyActivationTime > 0) {
+						if (lastPolicyActivationTime != null && lastPolicyActivationTime > 0) {
 							dbObj.setPolicyActivationTime(lastPolicyActivationTime);
 						}
 						needsUpdating = true;
-					} else if (lastKnownPolicyVersion == -1) {
+					} else if (lastKnownPolicyVersion != null && lastKnownPolicyVersion == -1) {
 						dbObj.setPolicyDownloadTime(pluginInfo.getPolicyDownloadTime());
 						dbObj.setPolicyActiveVersion(null);
 						dbObj.setPolicyActivationTime(null);
@@ -797,16 +797,16 @@ public class AssetMgr extends AssetMgrBase {
 						dbObj.setTagDownloadTime(pluginInfo.getTagDownloadTime());
 						needsUpdating = true;
 					}
-					long lastKnownTagVersion = pluginInfo.getTagActiveVersion();
-					long lastTagActivationTime = pluginInfo.getTagActivationTime();
+					Long lastKnownTagVersion = pluginInfo.getTagActiveVersion();
+					Long lastTagActivationTime = pluginInfo.getTagActivationTime();
 
-					if (lastKnownTagVersion > 0 && (dbObj.getTagActiveVersion() == null || !dbObj.getTagActiveVersion().equals(lastKnownTagVersion)))
{
+					if (lastKnownTagVersion != null && lastKnownTagVersion > 0 && (dbObj.getTagActiveVersion()
== null || !dbObj.getTagActiveVersion().equals(lastKnownTagVersion))) {
 						dbObj.setTagActiveVersion(lastKnownTagVersion);
-						if (lastTagActivationTime > 0) {
+						if (lastTagActivationTime != null && lastTagActivationTime > 0) {
 							dbObj.setTagActivationTime(lastTagActivationTime);
 						}
 						needsUpdating = true;
-					} else if (lastKnownTagVersion == -1) {
+					} else if (lastKnownTagVersion != null && lastKnownTagVersion == -1) {
 						dbObj.setTagDownloadTime(pluginInfo.getTagDownloadTime());
 						dbObj.setTagActiveVersion(null);
 						dbObj.setTagActivationTime(null);

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/5fe203f5/security-admin/src/main/java/org/apache/ranger/entity/XXPluginInfo.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXPluginInfo.java b/security-admin/src/main/java/org/apache/ranger/entity/XXPluginInfo.java
index 2196cdf..7b07bfc 100644
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXPluginInfo.java
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXPluginInfo.java
@@ -178,8 +178,6 @@ public class XXPluginInfo implements java.io.Serializable {
 			return false;
 		if (this == obj)
 			return true;
-		if (!super.equals(obj))
-			return false;
 		if (getClass() != obj.getClass())
 			return false;
 		XXPluginInfo other = (XXPluginInfo) obj;


Mime
View raw message