knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject knox git commit: KNOX-1195 - Some misc code cleanups
Date Tue, 06 Mar 2018 12:05:43 GMT
Repository: knox
Updated Branches:
  refs/heads/master e6a79a806 -> 5f9ee5a08


KNOX-1195 - Some misc code cleanups


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

Branch: refs/heads/master
Commit: 5f9ee5a080ef82abbf8f368cd9ae01bae205ec88
Parents: e6a79a8
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Tue Mar 6 12:05:30 2018 +0000
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Tue Mar 6 12:05:30 2018 +0000

----------------------------------------------------------------------
 .../discovery/ambari/AmbariClientCommon.java    |  8 ++----
 .../ambari/AmbariConfigurationMonitor.java      | 15 +++++-----
 .../ambari/AmbariDynamicServiceURLCreator.java  |  7 +++--
 .../ambari/AmbariServiceDiscovery.java          |  9 +++---
 .../filter/HadoopGroupProviderFilter.java       |  4 +--
 .../org/apache/knox/gateway/GatewayServer.java  |  7 ++---
 .../GenericProviderDeploymentContributor.java   |  2 +-
 .../impl/reporters/GraphiteMetricsReporter.java |  2 +-
 .../impl/reporters/JmxMetricsReporter.java      |  2 +-
 .../topology/impl/DefaultTopologyService.java   | 30 +++++++-------------
 .../simple/SimpleDescriptorHandler.java         |  9 +++---
 .../RemoteConfigurationRegistryJAASConfig.java  |  2 --
 .../knox/gateway/shell/AbstractRequest.java     | 15 ++--------
 .../knox/gateway/dispatch/DefaultDispatch.java  |  4 +--
 .../gateway/dispatch/GatewayDispatchFilter.java |  4 +--
 .../knox/gateway/util/X500PrincipalParser.java  |  6 ++--
 16 files changed, 52 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/5f9ee5a0/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariClientCommon.java
----------------------------------------------------------------------
diff --git a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariClientCommon.java
b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariClientCommon.java
index 1314305..c340056 100644
--- a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariClientCommon.java
+++ b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariClientCommon.java
@@ -18,12 +18,12 @@ package org.apache.knox.gateway.topology.discovery.ambari;
 
 import net.minidev.json.JSONArray;
 import net.minidev.json.JSONObject;
-import org.apache.knox.gateway.i18n.messages.MessagesFactory;
 import org.apache.knox.gateway.services.security.AliasService;
 import org.apache.knox.gateway.topology.discovery.ServiceDiscoveryConfig;
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Map.Entry;
 
 class AmbariClientCommon {
 
@@ -35,8 +35,6 @@ class AmbariClientCommon {
     static final String AMBARI_SERVICECONFIGS_URI =
                                     AMBARI_CLUSTERS_URI + "/%s/configurations/service_config_versions?is_current=true";
 
-    private static final AmbariServiceDiscoveryMessages log = MessagesFactory.get(AmbariServiceDiscoveryMessages.class);
-
     private RESTInvoker restClient;
 
 
@@ -87,8 +85,8 @@ class AmbariClientCommon {
 
                     Map<String, String> configProps = new HashMap<>();
                     JSONObject configProperties = (JSONObject) ((JSONObject) configuration).get("properties");
-                    for (String propertyName : configProperties.keySet()) {
-                        configProps.put(propertyName, String.valueOf(((JSONObject) configProperties).get(propertyName)));
+                    for (Entry<String, Object> entry : configProperties.entrySet())
{
+                        configProps.put(entry.getKey(), String.valueOf(entry.getValue()));
                     }
                     if (!serviceConfigurations.containsKey(serviceName)) {
                         serviceConfigurations.put(serviceName, new HashMap<>());

http://git-wip-us.apache.org/repos/asf/knox/blob/5f9ee5a0/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariConfigurationMonitor.java
----------------------------------------------------------------------
diff --git a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariConfigurationMonitor.java
b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariConfigurationMonitor.java
index a086956..b0aab4d 100644
--- a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariConfigurationMonitor.java
+++ b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariConfigurationMonitor.java
@@ -32,6 +32,7 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -218,8 +219,8 @@ class AmbariConfigurationMonitor implements ClusterConfigurationMonitor
{
             Properties props = new Properties();
             props.setProperty(PROP_CLUSTER_NAME, clusterName);
             props.setProperty(PROP_CLUSTER_SOURCE, address);
-            for (String name : configVersions.keySet()) {
-                props.setProperty(name, configVersions.get(name));
+            for (Entry<String, String> configVersion : configVersions.entrySet()) {
+                props.setProperty(configVersion.getKey(), configVersion.getValue());
             }
 
             persist(props, getConfigVersionsPersistenceFile(address, clusterName));
@@ -354,8 +355,8 @@ class AmbariConfigurationMonitor implements ClusterConfigurationMonitor
{
         // Build the set of configuration versions
         Map<String, String> configVersions = new HashMap<>();
         Map<String, Map<String, AmbariCluster.ServiceConfiguration>> serviceConfigs
= cluster.getServiceConfigurations();
-        for (String serviceName : serviceConfigs.keySet()) {
-            Map<String, AmbariCluster.ServiceConfiguration> configTypeVersionMap =
serviceConfigs.get(serviceName);
+        for (Entry<String, Map<String, AmbariCluster.ServiceConfiguration>> serviceConfig
: serviceConfigs.entrySet()) {
+            Map<String, AmbariCluster.ServiceConfiguration> configTypeVersionMap =
serviceConfig.getValue();
             for (AmbariCluster.ServiceConfiguration config : configTypeVersionMap.values())
{
                 String configType = config.getType();
                 String version = config.getVersion();
@@ -431,10 +432,10 @@ class AmbariConfigurationMonitor implements ClusterConfigurationMonitor
{
 
         configVersionsLock.readLock().lock();
         try {
-            for (String address : ambariClusterConfigVersions.keySet()) {
+            for (Entry<String, Map<String, Map<String, String>>> ambariClusterConfigVersion
: ambariClusterConfigVersions.entrySet()) {
                 List<String> clusterNames = new ArrayList<>();
-                clusterNames.addAll(ambariClusterConfigVersions.get(address).keySet());
-                result.put(address, clusterNames);
+                clusterNames.addAll(ambariClusterConfigVersion.getValue().keySet());
+                result.put(ambariClusterConfigVersion.getKey(), clusterNames);
             }
         } finally {
             configVersionsLock.readLock().unlock();

http://git-wip-us.apache.org/repos/asf/knox/blob/5f9ee5a0/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreator.java
----------------------------------------------------------------------
diff --git a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreator.java
b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreator.java
index 7ccd170..9263896 100644
--- a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreator.java
+++ b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreator.java
@@ -27,6 +27,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
 
 class AmbariDynamicServiceURLCreator implements ServiceURLCreator {
@@ -159,10 +160,10 @@ class AmbariDynamicServiceURLCreator implements ServiceURLCreator {
         String url = null;
         if (pattern != null) {
             url = pattern;
-            for (String placeHolder : placeholderValues.keySet()) {
-                String value = placeholderValues.get(placeHolder);
+            for (Entry<String, String> placeHolder : placeholderValues.entrySet())
{
+                String value = placeHolder.getValue();
                 if (value != null) {
-                    url = url.replace("{" + placeHolder + "}", value);
+                    url = url.replace("{" + placeHolder.getKey() + "}", value);
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/knox/blob/5f9ee5a0/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariServiceDiscovery.java
----------------------------------------------------------------------
diff --git a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariServiceDiscovery.java
b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariServiceDiscovery.java
index 957d723..bd794a3 100644
--- a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariServiceDiscovery.java
+++ b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariServiceDiscovery.java
@@ -24,6 +24,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Properties;
 
 import net.minidev.json.JSONArray;
@@ -155,7 +156,7 @@ class AmbariServiceDiscovery implements ServiceDiscovery {
     private AmbariConfigurationMonitor getConfigurationChangeMonitor() {
         AmbariConfigurationMonitor ambariMonitor = null;
         try {
-            Class clazz = Class.forName(GATEWAY_SERVICES_ACCESSOR_CLASS);
+            Class<?> clazz = Class.forName(GATEWAY_SERVICES_ACCESSOR_CLASS);
             if (clazz != null) {
                 Method m = clazz.getDeclaredMethod(GATEWAY_SERVICES_ACCESSOR_METHOD);
                 if (m != null) {
@@ -270,9 +271,9 @@ class AmbariServiceDiscovery implements ServiceDiscovery {
                                                                                         
           clusterName,
                                                                                         
           discoveryUser,
                                                                                         
           discoveryPwdAlias);
-        for (String serviceName : serviceConfigurations.keySet()) {
-            for (Map.Entry<String, AmbariCluster.ServiceConfiguration> serviceConfig
: serviceConfigurations.get(serviceName).entrySet()) {
-                cluster.addServiceConfiguration(serviceName, serviceConfig.getKey(), serviceConfig.getValue());
+        for (Entry<String, Map<String, AmbariCluster.ServiceConfiguration>> serviceConfiguration
: serviceConfigurations.entrySet()) {
+            for (Map.Entry<String, AmbariCluster.ServiceConfiguration> serviceConfig
: serviceConfiguration.getValue().entrySet()) {
+                cluster.addServiceConfiguration(serviceConfiguration.getKey(), serviceConfig.getKey(),
serviceConfig.getValue());
             }
         }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/5f9ee5a0/gateway-provider-identity-assertion-hadoop-groups/src/main/java/org/apache/knox/gateway/identityasserter/hadoop/groups/filter/HadoopGroupProviderFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-identity-assertion-hadoop-groups/src/main/java/org/apache/knox/gateway/identityasserter/hadoop/groups/filter/HadoopGroupProviderFilter.java
b/gateway-provider-identity-assertion-hadoop-groups/src/main/java/org/apache/knox/gateway/identityasserter/hadoop/groups/filter/HadoopGroupProviderFilter.java
index 7709f68..1459498 100644
--- a/gateway-provider-identity-assertion-hadoop-groups/src/main/java/org/apache/knox/gateway/identityasserter/hadoop/groups/filter/HadoopGroupProviderFilter.java
+++ b/gateway-provider-identity-assertion-hadoop-groups/src/main/java/org/apache/knox/gateway/identityasserter/hadoop/groups/filter/HadoopGroupProviderFilter.java
@@ -34,7 +34,7 @@ import org.apache.hadoop.security.Groups;
 /**
  * A filter that integrates the Hadoop {@link GroupMappingServiceProvider} for
  * looking up group membership of the authenticated (asserted) identity.
- * 
+ *
  * @since 0.11.0
  */
 public class HadoopGroupProviderFilter extends CommonIdentityAssertionFilter {
@@ -42,7 +42,7 @@ public class HadoopGroupProviderFilter extends CommonIdentityAssertionFilter
{
   /**
    * Logging
    */
-  public static HadoopGroupProviderMessages LOG = MessagesFactory
+  public static final HadoopGroupProviderMessages LOG = MessagesFactory
       .get(HadoopGroupProviderMessages.class);
 
   /**

http://git-wip-us.apache.org/repos/asf/knox/blob/5f9ee5a0/gateway-server/src/main/java/org/apache/knox/gateway/GatewayServer.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/GatewayServer.java b/gateway-server/src/main/java/org/apache/knox/gateway/GatewayServer.java
index 70eca7f..40a167d 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/GatewayServer.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/GatewayServer.java
@@ -114,7 +114,6 @@ public class GatewayServer {
   private static final GatewayMessages log = MessagesFactory.get(GatewayMessages.class);
   private static final Auditor auditor = AuditServiceFactory.getAuditService().getAuditor(AuditConstants.DEFAULT_AUDITOR_NAME,
       AuditConstants.KNOX_SERVICE_NAME, AuditConstants.KNOX_COMPONENT_NAME);
-  private static final String DEFAULT_CONNECTOR_NAME = "default";
 
   private static GatewayServer server;
   private static GatewayServices services;
@@ -317,11 +316,9 @@ public class GatewayServer {
             }
           }
           if (connector.getName() == null) {
-            log.startedGateway(
-                connector != null ? connector.getLocalPort() : -1);
+            log.startedGateway(connector.getLocalPort());
           } else {
-            log.startedGateway(connector != null ? connector.getName() : "",
-                connector != null ? connector.getLocalPort() : -1);
+            log.startedGateway(connector.getName(), connector.getLocalPort());
           }
         }
       }

http://git-wip-us.apache.org/repos/asf/knox/blob/5f9ee5a0/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/GenericProviderDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/GenericProviderDeploymentContributor.java
b/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/GenericProviderDeploymentContributor.java
index c8643bb..9a543b1 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/GenericProviderDeploymentContributor.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/GenericProviderDeploymentContributor.java
@@ -32,7 +32,7 @@ import java.util.Map;
 public class GenericProviderDeploymentContributor extends
     ProviderDeploymentContributorBase {
 
-  public static String FILTER_PARAM = "filter";
+  public static final String FILTER_PARAM = "filter";
 
   @Override
   public String getRole() {

http://git-wip-us.apache.org/repos/asf/knox/blob/5f9ee5a0/gateway-server/src/main/java/org/apache/knox/gateway/services/metrics/impl/reporters/GraphiteMetricsReporter.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/services/metrics/impl/reporters/GraphiteMetricsReporter.java
b/gateway-server/src/main/java/org/apache/knox/gateway/services/metrics/impl/reporters/GraphiteMetricsReporter.java
index 0707a95..fcb1c2c 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/services/metrics/impl/reporters/GraphiteMetricsReporter.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/services/metrics/impl/reporters/GraphiteMetricsReporter.java
@@ -31,7 +31,7 @@ import java.util.concurrent.TimeUnit;
 
 public class GraphiteMetricsReporter extends AbstractMetricsReporter {
 
-  public static String NAME = "graphite-reporter";
+  public static final String NAME = "graphite-reporter";
 
   private Graphite graphite;
   private GraphiteReporter reporter;

http://git-wip-us.apache.org/repos/asf/knox/blob/5f9ee5a0/gateway-server/src/main/java/org/apache/knox/gateway/services/metrics/impl/reporters/JmxMetricsReporter.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/services/metrics/impl/reporters/JmxMetricsReporter.java
b/gateway-server/src/main/java/org/apache/knox/gateway/services/metrics/impl/reporters/JmxMetricsReporter.java
index d108ee0..fff8ddf 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/services/metrics/impl/reporters/JmxMetricsReporter.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/services/metrics/impl/reporters/JmxMetricsReporter.java
@@ -26,7 +26,7 @@ import org.apache.knox.gateway.services.metrics.impl.DefaultMetricsService;
 
 public class JmxMetricsReporter extends AbstractMetricsReporter {
 
-  public static String NAME = "jmx-reporter";
+  public static final String NAME = "jmx-reporter";
 
   private JmxReporter jmxReporter;
 

http://git-wip-us.apache.org/repos/asf/knox/blob/5f9ee5a0/gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java
b/gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java
index ccd4130..28a7e61 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java
@@ -80,6 +80,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 
 import static org.apache.commons.digester3.binder.DigesterLoader.newLoader;
@@ -206,36 +207,25 @@ public class DefaultTopologyService
       Map<File, Topology> newTopologies) {
     ArrayList<TopologyEvent> events = new ArrayList<TopologyEvent>();
     // Go through the old topologies and find anything that was deleted.
-    for (File file : oldTopologies.keySet()) {
-      if (!newTopologies.containsKey(file)) {
-        events.add(new TopologyEvent(TopologyEvent.Type.DELETED, oldTopologies.get(file)));
+    for (Entry<File, Topology> oldTopology : oldTopologies.entrySet()) {
+      if (!newTopologies.containsKey(oldTopology.getKey())) {
+        events.add(new TopologyEvent(TopologyEvent.Type.DELETED, oldTopology.getValue()));
       }
     }
     // Go through the new topologies and figure out what was updated vs added.
-    for (File file : newTopologies.keySet()) {
-      if (oldTopologies.containsKey(file)) {
-        Topology oldTopology = oldTopologies.get(file);
-        Topology newTopology = newTopologies.get(file);
-        if (newTopology.getTimestamp() > oldTopology.getTimestamp()) {
-          events.add(new TopologyEvent(TopologyEvent.Type.UPDATED, newTopologies.get(file)));
+    for (Entry<File, Topology> newTopology : newTopologies.entrySet()) {
+      if (oldTopologies.containsKey(newTopology.getKey())) {
+        Topology oldTopology = oldTopologies.get(newTopology.getKey());
+        if (newTopology.getValue().getTimestamp() > oldTopology.getTimestamp()) {
+          events.add(new TopologyEvent(TopologyEvent.Type.UPDATED, newTopology.getValue()));
         }
       } else {
-        events.add(new TopologyEvent(TopologyEvent.Type.CREATED, newTopologies.get(file)));
+        events.add(new TopologyEvent(TopologyEvent.Type.CREATED, newTopology.getValue()));
       }
     }
     return events;
   }
 
-  private File calculateAbsoluteProvidersConfigDir(GatewayConfig config) {
-    File pcDir = new File(config.getGatewayProvidersConfigDir());
-    return pcDir.getAbsoluteFile();
-  }
-
-  private File calculateAbsoluteDescriptorsDir(GatewayConfig config) {
-    File descDir = new File(config.getGatewayDescriptorsDir());
-    return descDir.getAbsoluteFile();
-  }
-
   private File calculateAbsoluteTopologiesDir(GatewayConfig config) {
     File topoDir = new File(config.getGatewayTopologyDir());
     topoDir = topoDir.getAbsoluteFile();

http://git-wip-us.apache.org/repos/asf/knox/blob/5f9ee5a0/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
b/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
index db15094..a3d9406 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
@@ -30,6 +30,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 
 import org.apache.knox.gateway.GatewayServer;
@@ -457,11 +458,11 @@ public class SimpleDescriptorHandler {
                 // Params
                 Map<String, String> svcParams = serviceParams.get(serviceName);
                 if (svcParams != null) {
-                    for (String paramName : svcParams.keySet()) {
-                        if (!(paramName.toLowerCase()).startsWith(DISCOVERY_PARAM_PREFIX))
{
+                    for (Entry<String, String> svcParam : svcParams.entrySet()) {
+                        if (!(svcParam.getKey().toLowerCase()).startsWith(DISCOVERY_PARAM_PREFIX))
{
                             sw.write("        <param>\n");
-                            sw.write("            <name>" + paramName + "</name>\n");
-                            sw.write("            <value>" + svcParams.get(paramName)
+ "</value>\n");
+                            sw.write("            <name>" + svcParam.getKey() + "</name>\n");
+                            sw.write("            <value>" + svcParam.getValue() +
"</value>\n");
                             sw.write("        </param>\n");
                         }
                     }

http://git-wip-us.apache.org/repos/asf/knox/blob/5f9ee5a0/gateway-service-remoteconfig/src/main/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryJAASConfig.java
----------------------------------------------------------------------
diff --git a/gateway-service-remoteconfig/src/main/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryJAASConfig.java
b/gateway-service-remoteconfig/src/main/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryJAASConfig.java
index f75634b..c6dbf36 100644
--- a/gateway-service-remoteconfig/src/main/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryJAASConfig.java
+++ b/gateway-service-remoteconfig/src/main/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryJAASConfig.java
@@ -24,7 +24,6 @@ import org.apache.knox.gateway.services.security.AliasServiceException;
 
 import javax.security.auth.login.AppConfigurationEntry;
 import javax.security.auth.login.Configuration;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -63,7 +62,6 @@ class RemoteConfigurationRegistryJAASConfig extends Configuration {
         this.aliasService = aliasService;
 
         // Populate context entries
-        List<AppConfigurationEntry> appConfigEntries = new ArrayList<>();
         for (RemoteConfigurationRegistryConfig config : configs) {
             if (config.isSecureRegistry()) {
                 contextEntries.put(config.getName(), createEntries(config));

http://git-wip-us.apache.org/repos/asf/knox/blob/5f9ee5a0/gateway-shell/src/main/java/org/apache/knox/gateway/shell/AbstractRequest.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/AbstractRequest.java
b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/AbstractRequest.java
index a764950..e232d4d 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/AbstractRequest.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/AbstractRequest.java
@@ -29,6 +29,7 @@ import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.concurrent.Callable;
 import java.util.concurrent.Future;
 
@@ -53,19 +54,9 @@ public abstract class AbstractRequest<T> {
    * @param request
    * @param headers
    */
-  private void removeHeaders(HttpRequest request, Map<String, String> headers) {
-    for(String header : headers.keySet()) {
-      request.removeHeaders(header);
-    }
-  }
-
-  /**
-   * @param request
-   * @param headers
-   */
   private void addHeaders(HttpRequest request, Map<String, String> headers) {
-    for(String header : headers.keySet()) {
-      request.setHeader(header, headers.get(header));
+    for(Entry<String, String> header : headers.entrySet()) {
+      request.setHeader(header.getKey(), header.getValue());
     }
   }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/5f9ee5a0/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/DefaultDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/DefaultDispatch.java
b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/DefaultDispatch.java
index aeb33b2..c2c1b53 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/DefaultDispatch.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/DefaultDispatch.java
@@ -61,8 +61,8 @@ public class DefaultDispatch extends AbstractGatewayDispatch {
   protected static final String SET_COOKIE = "SET-COOKIE";
   protected static final String WWW_AUTHENTICATE = "WWW-AUTHENTICATE";
 
-  protected static SpiGatewayMessages LOG = MessagesFactory.get(SpiGatewayMessages.class);
-  protected static SpiGatewayResources RES = ResourcesFactory.get(SpiGatewayResources.class);
+  protected static final SpiGatewayMessages LOG = MessagesFactory.get(SpiGatewayMessages.class);
+  protected static final SpiGatewayResources RES = ResourcesFactory.get(SpiGatewayResources.class);
   protected static Auditor auditor = AuditServiceFactory.getAuditService().getAuditor(AuditConstants.DEFAULT_AUDITOR_NAME,
       AuditConstants.KNOX_SERVICE_NAME, AuditConstants.KNOX_COMPONENT_NAME);
 

http://git-wip-us.apache.org/repos/asf/knox/blob/5f9ee5a0/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilter.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilter.java
b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilter.java
index 7b887d1..8bef80d 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilter.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilter.java
@@ -37,9 +37,9 @@ import java.util.Map;
 
 public class GatewayDispatchFilter extends AbstractGatewayFilter {
 
-  private static Map<String, Adapter> METHOD_ADAPTERS = createMethodAdapters();
+  private static final Map<String, Adapter> METHOD_ADAPTERS = createMethodAdapters();
 
-  protected static SpiGatewayMessages LOG = MessagesFactory.get(SpiGatewayMessages.class);
+  protected static final SpiGatewayMessages LOG = MessagesFactory.get(SpiGatewayMessages.class);
 
   private Dispatch dispatch;
 

http://git-wip-us.apache.org/repos/asf/knox/blob/5f9ee5a0/gateway-util-common/src/main/java/org/apache/knox/gateway/util/X500PrincipalParser.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/main/java/org/apache/knox/gateway/util/X500PrincipalParser.java
b/gateway-util-common/src/main/java/org/apache/knox/gateway/util/X500PrincipalParser.java
index 80789b7..c13791a 100644
--- a/gateway-util-common/src/main/java/org/apache/knox/gateway/util/X500PrincipalParser.java
+++ b/gateway-util-common/src/main/java/org/apache/knox/gateway/util/X500PrincipalParser.java
@@ -25,8 +25,8 @@ import javax.security.auth.x500.X500Principal;
 
 public class X500PrincipalParser
 {
-  public static int LEASTSIGNIFICANT = 0;
-  public static int MOSTSIGNIFICANT = 1;
+  public static final int LEASTSIGNIFICANT = 0;
+  public static final int MOSTSIGNIFICANT = 1;
   
   public static final String attrCN = "CN";
   public static final String attrOU = "OU";
@@ -186,4 +186,4 @@ public class X500PrincipalParser
     }
   }
 
-}
\ No newline at end of file
+}


Mime
View raw message