Repository: knox Updated Branches: refs/heads/v0.14.0 cb982448b -> fa5fb634b
KNOX-1132 - Address Coverity Defects in gateway-service-remoteconfig (Phil Zampino via lmccay) Project: http://git-wip-us.apache.org/repos/asf/knox/repo Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/fa5fb634 Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/fa5fb634 Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/fa5fb634 Branch: refs/heads/v0.14.0 Commit: fa5fb634b60a4f43b787187ff81d5b807215bf4a Parents: cb98244 Author: Larry McCay <lmc...@hortonworks.com> Authored: Wed Dec 6 11:29:09 2017 -0500 Committer: Larry McCay <lmc...@hortonworks.com> Committed: Wed Dec 6 11:30:28 2017 -0500 ---------------------------------------------------------------------- .../config/remote/zk/CuratorClientService.java | 7 +++--- .../RemoteConfigurationRegistryJAASConfig.java | 24 ++++++++++++++------ 2 files changed, 21 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/knox/blob/fa5fb634/gateway-service-remoteconfig/src/main/java/org/apache/hadoop/gateway/service/config/remote/zk/CuratorClientService.java ---------------------------------------------------------------------- diff --git a/gateway-service-remoteconfig/src/main/java/org/apache/hadoop/gateway/service/config/remote/zk/CuratorClientService.java b/gateway-service-remoteconfig/src/main/java/org/apache/hadoop/gateway/service/config/remote/zk/CuratorClientService.java index 0000f48..f9b5ab3 100644 --- a/gateway-service-remoteconfig/src/main/java/org/apache/hadoop/gateway/service/config/remote/zk/CuratorClientService.java +++ b/gateway-service-remoteconfig/src/main/java/org/apache/hadoop/gateway/service/config/remote/zk/CuratorClientService.java @@ -366,9 +366,10 @@ class CuratorClientService implements ZooKeeperClientService { throws Exception { ChildData childData = pathChildrenCacheEvent.getData(); if (childData != null) { - delegate.childEvent(client, - adaptType(pathChildrenCacheEvent.getType()), - childData.getPath()); + ChildEntryListener.Type eventType = adaptType(pathChildrenCacheEvent.getType()); + if (eventType != null) { + delegate.childEvent(client, eventType, childData.getPath()); + } } } http://git-wip-us.apache.org/repos/asf/knox/blob/fa5fb634/gateway-service-remoteconfig/src/main/java/org/apache/hadoop/gateway/service/config/remote/zk/RemoteConfigurationRegistryJAASConfig.java ---------------------------------------------------------------------- diff --git a/gateway-service-remoteconfig/src/main/java/org/apache/hadoop/gateway/service/config/remote/zk/RemoteConfigurationRegistryJAASConfig.java b/gateway-service-remoteconfig/src/main/java/org/apache/hadoop/gateway/service/config/remote/zk/RemoteConfigurationRegistryJAASConfig.java index d51d7d5..0b5a693 100644 --- a/gateway-service-remoteconfig/src/main/java/org/apache/hadoop/gateway/service/config/remote/zk/RemoteConfigurationRegistryJAASConfig.java +++ b/gateway-service-remoteconfig/src/main/java/org/apache/hadoop/gateway/service/config/remote/zk/RemoteConfigurationRegistryJAASConfig.java @@ -36,6 +36,7 @@ class RemoteConfigurationRegistryJAASConfig extends Configuration { // Underlying SASL mechanisms supported enum SASLMechanism { + Unsupported, Kerberos, Digest } @@ -92,9 +93,16 @@ class RemoteConfigurationRegistryJAASConfig extends Configuration { } private AppConfigurationEntry[] createEntries(RemoteConfigurationRegistryConfig config) { - // Only supporting a single app config entry per configuration/context - AppConfigurationEntry[] result = new AppConfigurationEntry[1]; - result[0] = createEntry(config); + AppConfigurationEntry[] result = null; + + AppConfigurationEntry entry = createEntry(config); + if (entry != null) { + // Only supporting a single app config entry per configuration/context + result = new AppConfigurationEntry[1]; + result[0] = createEntry(config); + } else { + result = new AppConfigurationEntry[0]; + } return result; } @@ -130,9 +138,11 @@ class RemoteConfigurationRegistryJAASConfig extends Configuration { opts.put("principal", config.getPrincipal()); } - entry = new AppConfigurationEntry(getLoginModuleName(config.getRegistryType(), saslMechanism), - AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, - opts); + if (!opts.isEmpty()) { + entry = new AppConfigurationEntry(getLoginModuleName(config.getRegistryType(), saslMechanism), + AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, + opts); + } return entry; } @@ -155,7 +165,7 @@ class RemoteConfigurationRegistryJAASConfig extends Configuration { } private static SASLMechanism getSASLMechanism(String authType) { - SASLMechanism result = null; + SASLMechanism result = SASLMechanism.Unsupported; for (SASLMechanism at : SASLMechanism.values()) { if (at.name().equalsIgnoreCase(authType)) { result = at;