knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kris...@apache.org
Subject [5/5] knox git commit: KNOX-1664 - Miscellaneous code cleanup
Date Sat, 08 Dec 2018 14:29:58 GMT
KNOX-1664 - Miscellaneous code cleanup

* Unnecessary boxing/unboxing
* Collection.toArray()
* String concatenation in loop
* StringBuffer -> StringBuilder where possible
* Identical catch block collapse
* Inline redundant variable
* Collections methods (addAll, isEmpty)
* Use isEmpty where applicable
* Remove redundant initializer

Signed-off-by: Kevin Risden <krisden@apache.org>


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

Branch: refs/heads/master
Commit: f54e9d2d47ee5927ab102986a1d240049828ecc9
Parents: 6736393
Author: Kevin Risden <krisden@apache.org>
Authored: Sat Dec 8 08:54:39 2018 -0500
Committer: Kevin Risden <krisden@apache.org>
Committed: Sat Dec 8 09:28:17 2018 -0500

----------------------------------------------------------------------
 .../discovery/ambari/AmbariCluster.java         | 12 ++---
 .../discovery/ambari/AmbariComponent.java       | 10 ++--
 .../ambari/AmbariConfigurationMonitor.java      |  7 ++-
 .../discovery/ambari/PropertyEqualsHandler.java | 10 ++--
 .../discovery/ambari/ServiceURLFactory.java     |  7 +--
 .../ambari/ServiceURLPropertyConfig.java        |  4 +-
 .../ambari/AmbariConfigurationMonitorTest.java  |  2 +-
 .../loggers/test/TestMessageLogger.java         |  2 +-
 .../i18n/resources/ResourcesInvoker.java        |  2 +-
 .../gateway/ha/provider/URLManagerLoader.java   |  7 +--
 .../provider/impl/BaseZookeeperURLManager.java  |  4 +-
 .../provider/impl/HBaseZookeeperURLManager.java | 15 +++---
 .../provider/impl/HS2ZookeeperURLManager.java   | 18 +++----
 .../ha/provider/impl/HaDescriptorFactory.java   | 10 ++--
 .../ha/provider/impl/HaDescriptorManager.java   | 12 ++---
 .../provider/impl/KafkaZookeeperURLManager.java |  4 +-
 .../provider/impl/SOLRZookeeperURLManager.java  | 10 ++--
 .../HaProviderDeploymentContributorTest.java    | 10 ++--
 .../ha/provider/impl/DefaultHaProviderTest.java |  1 +
 .../filter/AbstractIdentityAssertionFilter.java | 12 ++---
 .../filter/CommonIdentityAssertionFilter.java   |  6 +--
 ...entityAsserterHttpServletRequestWrapper.java |  8 +--
 ...yAssertionHttpServletRequestWrapperTest.java |  2 +-
 .../UsernameFunctionDescriptorTest.java         |  7 +--
 .../function/UsernameFunctionProcessorTest.java | 16 +++---
 .../filter/HadoopGroupProviderFilter.java       |  2 +-
 .../DefaultIdentityAssertionFilterTest.java     |  4 +-
 .../impl/HostmapDeploymentContributor.java      |  3 +-
 .../impl/HostmapFunctionProcessorTest.java      | 18 +++----
 .../impl/InboundUrlFunctionProcessor.java       |  2 +-
 .../ServiceAddressFunctionProcessorTest.java    |  6 +--
 .../impl/ServiceHostFunctionProcessorTest.java  |  6 +--
 ...rviceMappedAddressFunctionProcessorTest.java |  6 +--
 .../ServiceMappedHostFunctionProcessorTest.java |  6 +--
 .../ServiceMappedUrlFunctionProcessorTest.java  |  6 +--
 .../impl/ServicePathFunctionProcessorTest.java  |  4 +-
 .../impl/ServicePortFunctionProcessorTest.java  |  6 +--
 .../impl/ServiceRegistryFunctionsTest.java      |  3 +-
 .../ServiceSchemeFunctionProcessorTest.java     |  6 +--
 .../impl/ServiceUrlFunctionProcessorTest.java   |  6 +--
 .../encrypturi/impl/EncryptUriProcessor.java    |  4 +-
 .../impl/EncryptDecryptUriProcessorTest.java    | 10 ++--
 .../SecureQueryEncryptDecryptProcessorTest.java |  6 +--
 .../UrlRewriteFunctionDescriptorFactory.java    |  4 +-
 .../api/UrlRewriteServletContextListener.java   |  2 +-
 .../api/UrlRewriteServletEnvironment.java       | 10 ++--
 .../api/UrlRewriteStepDescriptorFactory.java    |  4 +-
 .../filter/rewrite/ext/ScopedMatcher.java       |  4 +-
 .../rewrite/impl/FrontendFunctionProcessor.java |  3 +-
 .../filter/rewrite/impl/UrlRewriteRequest.java  | 10 ++--
 .../filter/rewrite/impl/UrlRewriteResponse.java | 10 ++--
 .../impl/UrlRewriteRulesDescriptorImpl.java     |  8 ++-
 .../impl/UrlRewriteStepProcessorHolder.java     |  9 ++--
 .../filter/rewrite/impl/UrlRewriteUtil.java     |  2 +-
 .../rewrite/impl/form/FormFilterReader.java     |  2 +-
 .../impl/html/HtmlImportFunctionProcessor.java  |  6 +--
 .../rewrite/impl/html/HtmlInfixProcessor.java   |  8 +--
 .../rewrite/impl/html/HtmlPostfixProcessor.java |  8 +--
 .../rewrite/impl/html/HtmlPrefixProcessor.java  |  6 +--
 .../rewrite/impl/xml/XmlFilterReader.java       |  6 +--
 .../impl/xml/XmlUrlRewriteRulesExporter.java    | 12 +----
 .../impl/xml/XmlUrlRewriteRulesImporter.java    |  3 +-
 .../impl/xml/XmlUrlRewriteStreamFilter.java     |  4 +-
 .../rewrite/api/UrlRewriteProcessorTest.java    |  3 +-
 .../UrlRewriteServletContextListenerTest.java   |  3 +-
 .../api/UrlRewriteServletFilterTest.java        |  2 +-
 .../rewrite/impl/UrlRewriteContextImplTest.java |  6 +--
 .../rewrite/impl/UrlRewriteResponseTest.java    |  2 +-
 .../gateway/filter/AclsAuthorizationFilter.java | 18 +++----
 .../jwt/filter/AbstractJWTFilter.java           |  3 +-
 .../filter/JWTAccessTokenAssertionFilter.java   |  4 +-
 .../jwt/filter/JWTFederationFilter.java         |  2 +-
 .../jwt/filter/SSOCookieFederationFilter.java   | 11 ++--
 .../federation/AbstractJWTFilterTest.java       |  4 +-
 .../federation/JWTFederationFilterTest.java     |  2 +-
 .../federation/SSOCookieProviderTest.java       |  4 +-
 .../pac4j/filter/Pac4jDispatcherFilter.java     |  2 +-
 .../gateway/pac4j/session/KnoxSessionStore.java |  2 +-
 .../filter/HeaderPreAuthFederationFilter.java   |  4 +-
 .../knox/gateway/deploy/impl/ShiroConfig.java   |  6 +--
 .../deploy/impl/ShiroDeploymentContributor.java |  2 +-
 .../filter/ShiroSubjectIdentityAdapter.java     |  8 +--
 .../shirorealm/KnoxLdapContextFactory.java      |  2 +-
 .../knox/gateway/shirorealm/KnoxLdapRealm.java  |  7 ++-
 .../webappsec/filter/StrictTransportFilter.java |  2 +-
 .../filter/XContentTypeOptionsFilter.java       |  2 +-
 .../webappsec/filter/XFrameOptionsFilter.java   |  2 +-
 .../webappsec/filter/XSSProtectionFilter.java   |  2 +-
 .../webappsec/StrictTransportFilterTest.java    |  2 +-
 .../webappsec/XFrameOptionsFilterTest.java      |  2 +-
 .../webappsec/XSSProtectionFilterTest.java      |  2 +-
 .../gateway/filter/CompositeEnumeration.java    |  1 +
 .../filter/XForwardedHeaderRequestWrapper.java  |  3 +-
 .../apache/knox/gateway/GatewayCommandLine.java |  3 +-
 .../org/apache/knox/gateway/GatewayFilter.java  |  3 +-
 .../org/apache/knox/gateway/GatewayServer.java  | 12 ++---
 .../org/apache/knox/gateway/GatewayServlet.java | 35 +++---------
 .../gateway/config/impl/GatewayConfigImpl.java  |  6 +--
 .../knox/gateway/deploy/DeploymentFactory.java  | 50 ++++++++---------
 .../impl/ApplicationDeploymentContributor.java  |  4 +-
 .../xml/XmlGatewayDescriptorExporter.java       |  4 +-
 .../xml/XmlGatewayDescriptorImporter.java       |  3 +-
 .../gateway/dispatch/UrlConnectionDispatch.java |  3 +-
 .../filter/BasicAuthChallengeFilter.java        |  2 +-
 .../filter/PortMappingHelperHandler.java        |  2 +-
 .../gateway/filter/RequestUpdateHandler.java    |  2 +-
 .../metrics/impl/DefaultMetricsService.java     | 12 ++---
 .../impl/DefaultServiceRegistryService.java     |  8 +--
 .../security/impl/DefaultAliasService.java      |  8 ++-
 .../security/impl/DefaultCryptoService.java     | 32 +++--------
 .../security/impl/DefaultKeystoreService.java   | 52 +++++-------------
 .../services/security/impl/JettySSLService.java | 21 +++-----
 .../topology/impl/DefaultTopologyService.java   | 33 ++----------
 .../DefaultServiceDiscoveryConfig.java          |  2 +-
 .../simple/ProviderConfigurationParser.java     |  8 ++-
 .../topology/validation/TopologyValidator.java  |  2 +-
 .../org/apache/knox/gateway/util/KnoxCLI.java   | 48 +++++++----------
 .../websockets/GatewayWebsocketHandler.java     |  8 ++-
 .../apache/knox/gateway/AuditLoggingTest.java   | 14 ++---
 .../knox/gateway/GatewayGlobalConfigTest.java   |  3 +-
 .../services/security/CryptoServiceTest.java    |  4 +-
 .../impl/DefaultTokenAuthorityServiceTest.java  | 20 +++----
 .../topology/DefaultTopologyServiceTest.java    |  2 +-
 .../PropertiesFileServiceDiscoveryTest.java     |  8 ++-
 .../PropertiesFileServiceDiscovery.java         |  6 +--
 .../apache/knox/gateway/util/KnoxCLITest.java   | 29 +++++-----
 .../knox/gateway/websockets/BadUrlTest.java     |  5 +-
 .../gateway/websockets/WebsocketEchoTest.java   |  5 +-
 .../WebsocketMultipleConnectionTest.java        |  5 +-
 .../service/admin/TopologiesResource.java       |  4 +-
 .../gateway/service/health/MetricsResource.java |  5 +-
 .../gateway/service/health/PingResource.java    |  8 +--
 .../service/knoxtoken/TokenResource.java        | 16 +++---
 .../knox/gateway/dispatch/NiFiDispatch.java     |  2 +-
 .../knox/gateway/dispatch/NiFiHaDispatch.java   |  2 +-
 .../knox/gateway/dispatch/NiFiResponseUtil.java |  2 +-
 .../config/remote/zk/CuratorClientService.java  |  6 +--
 .../RemoteConfigurationRegistryJAASConfig.java  |  4 +-
 .../util/RemoteRegistryConfigTestUtils.java     | 44 ++++++++-------
 .../service/test/ServiceTestResource.java       |  3 +-
 .../AbstractJavaConsoleCredentialCollector.java |  5 +-
 .../apache/knox/gateway/shell/KnoxSession.java  |  8 +--
 .../org/apache/knox/gateway/shell/KnoxSh.java   | 29 ++++------
 .../apache/knox/gateway/shell/hbase/HBase.java  |  3 +-
 .../shell/manager/DeployResourceRequest.java    |  6 +--
 .../shell/manager/ListResourcesRequest.java     |  6 +--
 .../shell/manager/ListTopologiesRequest.java    |  4 +-
 .../gateway/shell/manager/ResourceType.java     |  2 +-
 .../shell/manager/UndeployResourceRequest.java  |  4 +-
 .../dispatch/AbstractGatewayDispatch.java       |  3 +-
 .../dispatch/CappedBufferHttpEntity.java        |  2 +-
 .../dispatch/DefaultHttpClientFactory.java      |  2 +-
 .../gateway/dispatch/HadoopAuthCookieStore.java |  2 +-
 .../gateway/dispatch/InputStreamEntity.java     | 21 ++++----
 .../dispatch/PartiallyRepeatableHttpEntity.java |  2 +-
 .../gateway/filter/AbstractGatewayFilter.java   |  5 +-
 .../knox/gateway/security/GroupPrincipal.java   |  2 +-
 .../gateway/security/ImpersonatedPrincipal.java |  2 +-
 .../knox/gateway/security/PrimaryPrincipal.java |  2 +-
 .../knox/gateway/security/PromptUtils.java      |  4 +-
 .../knox/gateway/security/SubjectUtils.java     |  2 +-
 .../knox/gateway/security/UsernamePassword.java |  2 +-
 .../principal/SimplePrincipalMapper.java        |  6 +--
 .../security/impl/BaseKeystoreService.java      | 34 ++----------
 .../security/impl/CMFKeystoreService.java       |  2 +-
 .../security/impl/CMFMasterService.java         |  7 +--
 .../security/impl/ConfigurableEncryptor.java    |  9 ++--
 .../services/security/token/impl/JWTToken.java  |  8 +--
 .../apache/knox/gateway/topology/Version.java   | 12 ++---
 .../apache/knox/gateway/GatewayTestConfig.java  |  4 +-
 .../apache/knox/gateway/GatewayTestDriver.java  |  2 +-
 .../apache/knox/gateway/SecureClusterTest.java  |  3 +-
 .../knox/gateway/SecureKnoxShellTest.java       |  8 +--
 .../java/org/apache/knox/gateway/ShellTest.java |  5 +-
 .../java/org/apache/knox/test/TestUtils.java    |  6 +--
 .../knox/test/mock/MockRequestMatcher.java      |  5 +-
 .../knox/gateway/GatewayAdminFuncTest.java      |  5 +-
 .../gateway/GatewayAdminTopologyFuncTest.java   | 15 +++---
 .../knox/gateway/GatewayBasicFuncTest.java      | 38 ++++++-------
 .../knox/gateway/GatewayDeployFuncTest.java     |  3 +-
 .../knox/gateway/GatewayHealthFuncTest.java     |  5 +-
 .../GatewayLdapDynamicGroupFuncTest.java        |  5 +-
 .../knox/gateway/GatewayLdapGroupFuncTest.java  |  5 +-
 .../gateway/GatewayLdapPosixGroupFuncTest.java  |  5 +-
 .../gateway/GatewayLocalServiceFuncTest.java    |  5 +-
 .../GatewayPortMappingDisableFeatureTest.java   |  3 +-
 .../gateway/GatewayPortMappingFuncTest.java     |  3 +-
 .../knox/gateway/GatewaySampleFuncTest.java     |  5 +-
 .../apache/knox/gateway/GatewayUIFuncTest.java  |  5 +-
 .../apache/knox/gateway/Knox242FuncTest.java    |  5 +-
 .../gateway/KnoxCliLdapFuncTestNegative.java    | 10 ++--
 .../gateway/KnoxCliLdapFuncTestPositive.java    | 10 ++--
 .../apache/knox/gateway/KnoxCliSysBindTest.java | 10 ++--
 .../apache/knox/gateway/WebHdfsHaFuncTest.java  |  5 +-
 .../monitor/RemoteConfigurationMonitorTest.java |  2 +-
 .../gateway/audit/log4j/appender/JdbmQueue.java |  6 +--
 .../appender/JdbmStoreAndForwardAppender.java   |  4 +-
 .../audit/log4j/audit/Log4jAuditContext.java    | 18 +++----
 .../gateway/audit/log4j/audit/Log4jAuditor.java |  4 +-
 .../correlation/Log4jCorrelationContext.java    | 12 ++---
 .../knox/gateway/util/CertificateUtils.java     |  4 +-
 .../org/apache/knox/gateway/util/HttpUtils.java |  2 +-
 .../org/apache/knox/gateway/util/JsonPath.java  | 31 +++++------
 .../org/apache/knox/gateway/util/JsonUtils.java |  6 ---
 .../java/org/apache/knox/gateway/util/Urls.java | 18 +++----
 .../knox/gateway/util/X500PrincipalParser.java  | 23 ++++----
 .../apache/knox/gateway/util/JsonPathTest.java  |  1 +
 .../impl/DefaultConfigurationInjector.java      |  8 +--
 .../apache/knox/gateway/config/FuncTest.java    | 14 ++---
 .../knox/gateway/config/OptionalTest.java       |  2 +-
 .../BeanConfigurationAdapterDescriptorTest.java |  6 +--
 .../impl/BeanConfigurationAdapterTest.java      |  2 +-
 .../apache/knox/gateway/launcher/Config.java    |  4 +-
 .../apache/knox/gateway/launcher/Invoker.java   |  6 +--
 .../apache/knox/gateway/launcher/Launcher.java  | 29 ++--------
 .../knox/gateway/launcher/ConfigTest.java       |  4 +-
 .../knox/gateway/util/urltemplate/Builder.java  |  6 +--
 .../knox/gateway/util/urltemplate/Expander.java | 57 ++++++++++----------
 .../knox/gateway/util/urltemplate/Function.java |  3 +-
 .../knox/gateway/util/urltemplate/Matcher.java  |  7 ++-
 .../knox/gateway/util/urltemplate/Parser.java   | 17 +++---
 .../knox/gateway/util/urltemplate/Segment.java  |  4 +-
 .../knox/gateway/util/urltemplate/Template.java | 10 ++--
 .../knox/gateway/util/urltemplate/Token.java    |  8 +--
 .../gateway/util/urltemplate/ExpanderTest.java  |  8 +--
 .../gateway/util/urltemplate/FunctionTest.java  |  4 +-
 .../gateway/util/urltemplate/RewriterTest.java  |  4 +-
 227 files changed, 716 insertions(+), 1087 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariCluster.java
----------------------------------------------------------------------
diff --git a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariCluster.java b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariCluster.java
index 6146fdc..f098b75 100644
--- a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariCluster.java
+++ b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariCluster.java
@@ -147,9 +147,7 @@ class AmbariCluster implements ServiceDiscovery.Cluster {
 
     @Override
     public List<String> getServiceURLs(String serviceName, Map<String, String> serviceParams) {
-        List<String> urls = new ArrayList<>();
-        urls.addAll(urlFactory.create(serviceName, serviceParams));
-        return urls;
+        return new ArrayList<>(urlFactory.create(serviceName, serviceParams));
     }
 
     @Override
@@ -253,7 +251,7 @@ class AmbariCluster implements ServiceDiscovery.Cluster {
         }
 
         private String applyPortToEnsemble(String ensemble, String port) {
-            String updatedEnsemble = "";
+            StringBuilder updatedEnsemble = new StringBuilder();
 
             String[] hosts = ensemble.split(",");
             int index = 0;
@@ -262,13 +260,13 @@ class AmbariCluster implements ServiceDiscovery.Cluster {
                 if (portIndex > 0) {
                     host = host.substring(0, portIndex);
                 }
-                updatedEnsemble += host + ":" + port;
+                updatedEnsemble.append(host).append(":").append(port);
                 if (++index < hosts.length) {
-                    updatedEnsemble += ",";
+                    updatedEnsemble.append(",");
                 }
             }
 
-            return updatedEnsemble;
+            return updatedEnsemble.toString();
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariComponent.java
----------------------------------------------------------------------
diff --git a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariComponent.java b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariComponent.java
index f694ee8..7e7ceba 100644
--- a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariComponent.java
+++ b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariComponent.java
@@ -23,14 +23,14 @@ import java.util.Map;
 
 class AmbariComponent {
 
-    private String clusterName = null;
-    private String serviceName = null;
-    private String name        = null;
-    private String version     = null;
+    private String clusterName;
+    private String serviceName;
+    private String name;
+    private String version;
 
     private List<String> hostNames = new ArrayList<>();
 
-    private Map<String, String> properties = null;
+    private Map<String, String> properties;
 
     AmbariComponent(String              name,
                     String              version,

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/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 2d61280..141df87 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
@@ -76,7 +76,7 @@ class AmbariConfigurationMonitor implements ClusterConfigurationMonitor {
 
     PollingConfigAnalyzer internalMonitor;
 
-    GatewayConfig gatewayConfig = null;
+    GatewayConfig gatewayConfig;
 
     static String getType() {
         return TYPE;
@@ -407,8 +407,7 @@ class AmbariConfigurationMonitor implements ClusterConfigurationMonitor {
         configVersionsLock.readLock().lock();
         try {
             for (Entry<String, Map<String, Map<String, String>>> ambariClusterConfigVersion : ambariClusterConfigVersions.entrySet()) {
-                List<String> clusterNames = new ArrayList<>();
-                clusterNames.addAll(ambariClusterConfigVersion.getValue().keySet());
+              List<String> clusterNames = new ArrayList<>(ambariClusterConfigVersion.getValue().keySet());
                 result.put(ambariClusterConfigVersion.getKey(), clusterNames);
             }
         } finally {
@@ -469,7 +468,7 @@ class AmbariConfigurationMonitor implements ClusterConfigurationMonitor {
         private static final int DEFAULT_POLLING_INTERVAL = 60;
 
         // Polling interval in seconds
-        private int interval = DEFAULT_POLLING_INTERVAL;
+        private int interval;
 
         private AmbariConfigurationMonitor delegate;
 

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/PropertyEqualsHandler.java
----------------------------------------------------------------------
diff --git a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/PropertyEqualsHandler.java b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/PropertyEqualsHandler.java
index 83a7542..1af52ae 100644
--- a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/PropertyEqualsHandler.java
+++ b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/PropertyEqualsHandler.java
@@ -19,11 +19,11 @@ package org.apache.knox.gateway.topology.discovery.ambari;
 
 class PropertyEqualsHandler implements ConditionalValueHandler {
 
-    private String serviceName                        = null;
-    private String propertyName                       = null;
-    private String propertyValue                      = null;
-    private ConditionalValueHandler affirmativeResult = null;
-    private ConditionalValueHandler negativeResult    = null;
+    private String serviceName;
+    private String propertyName;
+    private String propertyValue;
+    private ConditionalValueHandler affirmativeResult;
+    private ConditionalValueHandler negativeResult;
 
     PropertyEqualsHandler(String                  serviceName,
                           String                  propertyName,

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/ServiceURLFactory.java
----------------------------------------------------------------------
diff --git a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/ServiceURLFactory.java b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/ServiceURLFactory.java
index e897604..fa9fa39 100644
--- a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/ServiceURLFactory.java
+++ b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/ServiceURLFactory.java
@@ -29,7 +29,7 @@ public class ServiceURLFactory {
 
   private Map<String, ServiceURLCreator> urlCreators = new HashMap<>();
 
-  private ServiceURLCreator defaultURLCreator = null;
+  private ServiceURLCreator defaultURLCreator;
 
 
   private ServiceURLFactory(AmbariCluster cluster) {
@@ -69,16 +69,13 @@ public class ServiceURLFactory {
    * @return A List of service URL strings; the list may be empty.
    */
   public List<String> create(String service, Map<String, String> serviceParams) {
-    List<String> urls = new ArrayList<>();
 
     ServiceURLCreator creator = urlCreators.get(service);
     if (creator == null) {
       creator = defaultURLCreator;
     }
 
-    urls.addAll(creator.create(service, serviceParams));
-
-    return urls;
+    return new ArrayList<>(creator.create(service, serviceParams));
   }
 
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/ServiceURLPropertyConfig.java
----------------------------------------------------------------------
diff --git a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/ServiceURLPropertyConfig.java b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/ServiceURLPropertyConfig.java
index 4d8864f..25eedc6 100644
--- a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/ServiceURLPropertyConfig.java
+++ b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/ServiceURLPropertyConfig.java
@@ -104,7 +104,7 @@ class ServiceURLPropertyConfig {
             for (int i=0; i < serviceNodes.getLength(); i++) {
                 Node serviceNode = serviceNodes.item(i);
                 String serviceName = serviceNode.getAttributes().getNamedItem(ATTR_NAME).getNodeValue();
-                properties.put(serviceName, new HashMap<String, Property>());
+                properties.put(serviceName, new HashMap<>());
 
                 Node urlPatternNode = (Node) URL_PATTERN.evaluate(serviceNode, XPathConstants.NODE);
                 if (urlPatternNode != null) {
@@ -252,7 +252,7 @@ class ServiceURLPropertyConfig {
         String service;
         String serviceConfig;
         String value;
-        ConditionalValueHandler conditionHandler = null;
+        ConditionalValueHandler conditionHandler;
 
         private Property(String type,
                          String propertyName,

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariConfigurationMonitorTest.java
----------------------------------------------------------------------
diff --git a/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariConfigurationMonitorTest.java b/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariConfigurationMonitorTest.java
index 449a2a5..fcdbcad 100644
--- a/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariConfigurationMonitorTest.java
+++ b/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariConfigurationMonitorTest.java
@@ -149,7 +149,7 @@ public class AmbariConfigurationMonitorTest {
 //            System.out.println("Cluster config changed: " + cname + " @ " + src);
             // Record the notification
             Integer notificationCount  = changeNotifications.computeIfAbsent(src, s -> new HashMap<>())
-                                                            .computeIfAbsent(cname, c -> Integer.valueOf(0));
+                                                            .computeIfAbsent(cname, c -> 0);
             changeNotifications.get(src).put(cname, (notificationCount+=1));
 
             // Update the config version

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-i18n/src/main/java/org/apache/knox/gateway/i18n/messages/loggers/test/TestMessageLogger.java
----------------------------------------------------------------------
diff --git a/gateway-i18n/src/main/java/org/apache/knox/gateway/i18n/messages/loggers/test/TestMessageLogger.java b/gateway-i18n/src/main/java/org/apache/knox/gateway/i18n/messages/loggers/test/TestMessageLogger.java
index 1c31444..2166337 100644
--- a/gateway-i18n/src/main/java/org/apache/knox/gateway/i18n/messages/loggers/test/TestMessageLogger.java
+++ b/gateway-i18n/src/main/java/org/apache/knox/gateway/i18n/messages/loggers/test/TestMessageLogger.java
@@ -26,7 +26,7 @@ import java.util.List;
 
 public class TestMessageLogger implements MessageLogger {
 
-  public final List<TestMessageRecord> records = Collections.synchronizedList( new ArrayList<TestMessageRecord>() );
+  public final List<TestMessageRecord> records = Collections.synchronizedList(new ArrayList<>() );
 
   public final String name;
 

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-i18n/src/main/java/org/apache/knox/gateway/i18n/resources/ResourcesInvoker.java
----------------------------------------------------------------------
diff --git a/gateway-i18n/src/main/java/org/apache/knox/gateway/i18n/resources/ResourcesInvoker.java b/gateway-i18n/src/main/java/org/apache/knox/gateway/i18n/resources/ResourcesInvoker.java
index c551366..77bf113 100644
--- a/gateway-i18n/src/main/java/org/apache/knox/gateway/i18n/resources/ResourcesInvoker.java
+++ b/gateway-i18n/src/main/java/org/apache/knox/gateway/i18n/resources/ResourcesInvoker.java
@@ -85,7 +85,7 @@ public class ResourcesInvoker implements InvocationHandler {
     return pattern;
   }
 
-  protected static final String getDefaultPattern( final Method method ) {
+  protected static String getDefaultPattern(final Method method ) {
     final String prefix = method.getName();
     String suffix;
     final int params = method.getParameterTypes().length;

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/URLManagerLoader.java
----------------------------------------------------------------------
diff --git a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/URLManagerLoader.java b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/URLManagerLoader.java
index aff38c7..f0fe690 100644
--- a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/URLManagerLoader.java
+++ b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/URLManagerLoader.java
@@ -19,7 +19,6 @@ package org.apache.knox.gateway.ha.provider;
 
 import org.apache.knox.gateway.ha.provider.impl.DefaultURLManager;
 
-import java.util.Iterator;
 import java.util.ServiceLoader;
 
 public class URLManagerLoader {
@@ -28,10 +27,8 @@ public class URLManagerLoader {
     if (config != null) {
       ServiceLoader<URLManager> loader = ServiceLoader.load(URLManager.class);
       if ( loader != null ) {
-        Iterator<URLManager> iterator = loader.iterator();
-        while ( iterator.hasNext() ) {
-          URLManager urlManager = iterator.next();
-          if ( urlManager.supportsConfig(config) ) {
+        for (URLManager urlManager : loader) {
+          if (urlManager.supportsConfig(config)) {
             urlManager.setConfig(config);
             return urlManager;
           }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/BaseZookeeperURLManager.java
----------------------------------------------------------------------
diff --git a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/BaseZookeeperURLManager.java b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/BaseZookeeperURLManager.java
index 6107d2f..c1005ee 100644
--- a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/BaseZookeeperURLManager.java
+++ b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/BaseZookeeperURLManager.java
@@ -72,7 +72,7 @@ public abstract class BaseZookeeperURLManager implements URLManager {
     }
 
     String zookeeperEnsemble = config.getZookeeperEnsemble();
-    return zookeeperEnsemble != null && (zookeeperEnsemble.trim().length() > 0);
+    return zookeeperEnsemble != null && (!zookeeperEnsemble.trim().isEmpty());
   }
 
   @Override
@@ -198,7 +198,7 @@ public abstract class BaseZookeeperURLManager implements URLManager {
    * @return Apache HttpClient
    */
   private CloseableHttpClient buildHttpClient() {
-    CloseableHttpClient client = null;
+    CloseableHttpClient client;
 
     // Construct a HttpClient with short term timeout
     RequestConfig.Builder requestBuilder = RequestConfig.custom()

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/HBaseZookeeperURLManager.java
----------------------------------------------------------------------
diff --git a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/HBaseZookeeperURLManager.java b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/HBaseZookeeperURLManager.java
index 91f7971..a260774 100644
--- a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/HBaseZookeeperURLManager.java
+++ b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/HBaseZookeeperURLManager.java
@@ -78,7 +78,7 @@ public class HBaseZookeeperURLManager extends BaseZookeeperURLManager {
   @Override
   protected String getServiceName() {
     return "WEBHBASE";
-  };
+  }
 
   @Override
   protected String getZookeeperNamespace() {
@@ -149,14 +149,11 @@ public class HBaseZookeeperURLManager extends BaseZookeeperURLManager {
   private String constructURL(String serverInfo) {
     String scheme = "http";
 
-    StringBuffer buffer = new StringBuffer();
-    buffer.append(scheme);
-    buffer.append("://");
     // Strip off the host name
-    buffer.append(serverInfo.substring(0, serverInfo.indexOf(',')));
-    buffer.append(":");
-    buffer.append(PORT_NUMBER);
-
-    return buffer.toString();
+    return scheme +
+               "://" +
+               serverInfo.substring(0, serverInfo.indexOf(',')) +
+               ":" +
+               PORT_NUMBER;
   }
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/HS2ZookeeperURLManager.java
----------------------------------------------------------------------
diff --git a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/HS2ZookeeperURLManager.java b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/HS2ZookeeperURLManager.java
index e7855b3..112d3df 100644
--- a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/HS2ZookeeperURLManager.java
+++ b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/HS2ZookeeperURLManager.java
@@ -56,7 +56,7 @@ public class HS2ZookeeperURLManager extends DefaultURLManager {
     }
     String zookeeperEnsemble = config.getZookeeperEnsemble();
     String zookeeperNamespace = config.getZookeeperNamespace();
-    if ( zookeeperEnsemble != null && zookeeperNamespace != null && zookeeperEnsemble.trim().length() > 0 && zookeeperNamespace.trim().length() > 0) {
+    if ( zookeeperEnsemble != null && zookeeperNamespace != null && !zookeeperEnsemble.trim().isEmpty() && !zookeeperNamespace.trim().isEmpty()) {
       return true;
     }
     return false;
@@ -116,15 +116,13 @@ public class HS2ZookeeperURLManager extends DefaultURLManager {
         }
       }
     }
-    StringBuffer buffer = new StringBuffer();
-    buffer.append(scheme);
-    buffer.append("://");
-    buffer.append(host);
-    buffer.append(":");
-    buffer.append(port);
-    buffer.append("/");
-    buffer.append(httpPath);
-    return buffer.toString();
+    return scheme +
+               "://" +
+               host +
+               ":" +
+               port +
+               "/" +
+               httpPath;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/HaDescriptorFactory.java
----------------------------------------------------------------------
diff --git a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/HaDescriptorFactory.java b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/HaDescriptorFactory.java
index 0637cec..4ee4dd4 100644
--- a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/HaDescriptorFactory.java
+++ b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/HaDescriptorFactory.java
@@ -52,19 +52,19 @@ public abstract class HaDescriptorFactory implements HaServiceConfigConstants {
       int failoverSleep = DEFAULT_FAILOVER_SLEEP;
       int maxRetryAttempts = DEFAULT_MAX_RETRY_ATTEMPTS;
       int retrySleep = DEFAULT_RETRY_SLEEP;
-      if (enabledValue != null && enabledValue.trim().length() > 0) {
+      if (enabledValue != null && !enabledValue.trim().isEmpty()) {
          enabled = Boolean.parseBoolean(enabledValue);
       }
-      if (maxFailoverAttemptsValue != null && maxFailoverAttemptsValue.trim().length() > 0) {
+      if (maxFailoverAttemptsValue != null && !maxFailoverAttemptsValue.trim().isEmpty()) {
          maxFailoverAttempts = Integer.parseInt(maxFailoverAttemptsValue);
       }
-      if (failoverSleepValue != null && failoverSleepValue.trim().length() > 0) {
+      if (failoverSleepValue != null && !failoverSleepValue.trim().isEmpty()) {
          failoverSleep = Integer.parseInt(failoverSleepValue);
       }
-      if (maxRetryAttemptsValue != null && maxRetryAttemptsValue.trim().length() > 0) {
+      if (maxRetryAttemptsValue != null && !maxRetryAttemptsValue.trim().isEmpty()) {
          maxRetryAttempts = Integer.parseInt(maxRetryAttemptsValue);
       }
-      if (retrySleepValue != null && retrySleepValue.trim().length() > 0) {
+      if (retrySleepValue != null && !retrySleepValue.trim().isEmpty()) {
          retrySleep = Integer.parseInt(retrySleepValue);
       }
       DefaultHaServiceConfig serviceConfig = new DefaultHaServiceConfig(serviceName);

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/HaDescriptorManager.java
----------------------------------------------------------------------
diff --git a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/HaDescriptorManager.java b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/HaDescriptorManager.java
index 59727f7..f1ec065 100644
--- a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/HaDescriptorManager.java
+++ b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/HaDescriptorManager.java
@@ -68,10 +68,7 @@ public class HaDescriptorManager implements HaDescriptorConstants {
 
          Transformer t = XmlUtils.getTransformer( true, true, 2, false );
          XmlUtils.writeXml( document, writer, t );
-      } catch (ParserConfigurationException e) {
-         LOG.failedToWriteHaDescriptor(e);
-         throw new IOException(e);
-      } catch (TransformerException e) {
+      } catch (ParserConfigurationException | TransformerException e) {
          LOG.failedToWriteHaDescriptor(e);
          throw new IOException(e);
       }
@@ -96,14 +93,11 @@ public class HaDescriptorManager implements HaDescriptorConstants {
                descriptor.addServiceConfig(config);
             }
          }
-      } catch (ParserConfigurationException e) {
-         LOG.failedToLoadHaDescriptor(e);
-         throw new IOException(e);
-      } catch (SAXException e) {
+      } catch (ParserConfigurationException | SAXException e) {
          LOG.failedToLoadHaDescriptor(e);
          throw new IOException(e);
       }
-      return descriptor;
+     return descriptor;
    }
 
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/KafkaZookeeperURLManager.java
----------------------------------------------------------------------
diff --git a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/KafkaZookeeperURLManager.java b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/KafkaZookeeperURLManager.java
index f09fc15..a94834b 100644
--- a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/KafkaZookeeperURLManager.java
+++ b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/KafkaZookeeperURLManager.java
@@ -82,7 +82,7 @@ public class KafkaZookeeperURLManager extends BaseZookeeperURLManager {
   @Override
   protected String getServiceName() {
     return "KAFKA";
-  };
+  }
 
   // -------------------------------------------------------------------------------------
   // Private methods
@@ -131,7 +131,7 @@ public class KafkaZookeeperURLManager extends BaseZookeeperURLManager {
   private String constructURL(String serverInfo) throws ParseException {
     String scheme = "http";
 
-    StringBuffer buffer = new StringBuffer();
+    StringBuilder buffer = new StringBuilder();
 
     buffer.append(scheme);
     buffer.append("://");

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/SOLRZookeeperURLManager.java
----------------------------------------------------------------------
diff --git a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/SOLRZookeeperURLManager.java b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/SOLRZookeeperURLManager.java
index 24a9e53..582fc14 100644
--- a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/SOLRZookeeperURLManager.java
+++ b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/SOLRZookeeperURLManager.java
@@ -62,7 +62,7 @@ public class SOLRZookeeperURLManager extends BaseZookeeperURLManager {
   @Override
   protected String getServiceName() {
     return "SOLR";
-  };
+  }
 
   // -------------------------------------------------------------------------------------
   // Private methods
@@ -106,10 +106,8 @@ public class SOLRZookeeperURLManager extends BaseZookeeperURLManager {
   private String constructURL(String serverInfo) {
     String scheme = "http";
 
-    StringBuffer buffer = new StringBuffer();
-    buffer.append(scheme);
-    buffer.append("://");
-    buffer.append(serverInfo.replace("_", "/"));
-    return buffer.toString();
+    return scheme +
+               "://" +
+               serverInfo.replace("_", "/");
   }
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/deploy/HaProviderDeploymentContributorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/deploy/HaProviderDeploymentContributorTest.java b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/deploy/HaProviderDeploymentContributorTest.java
index e948ca9..e3f3ba4 100644
--- a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/deploy/HaProviderDeploymentContributorTest.java
+++ b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/deploy/HaProviderDeploymentContributorTest.java
@@ -306,34 +306,34 @@ public class HaProviderDeploymentContributorTest {
 
       builder.append(HaServiceConfigConstants.CONFIG_PARAM_ENABLED);
       builder.append(HaServiceConfigConstants.CONFIG_PAIR_DELIMITER);
-      builder.append(String.valueOf(enabled));
+      builder.append(enabled);
 
       if (maxRetryAttempts > -1) {
          builder.append(HaServiceConfigConstants.CONFIG_PAIRS_DELIMITER);
          builder.append(HaServiceConfigConstants.CONFIG_PARAM_MAX_RETRY_ATTEMPTS);
          builder.append(HaServiceConfigConstants.CONFIG_PAIR_DELIMITER);
-         builder.append(String.valueOf(maxRetryAttempts));
+         builder.append(maxRetryAttempts);
       }
 
       if (retrySleep > -1) {
          builder.append(HaServiceConfigConstants.CONFIG_PAIRS_DELIMITER);
          builder.append(HaServiceConfigConstants.CONFIG_PARAM_RETRY_SLEEP);
          builder.append(HaServiceConfigConstants.CONFIG_PAIR_DELIMITER);
-         builder.append(String.valueOf(retrySleep));
+         builder.append(retrySleep);
       }
 
       if (maxFailoverAttempts > -1) {
          builder.append(HaServiceConfigConstants.CONFIG_PAIRS_DELIMITER);
          builder.append(HaServiceConfigConstants.CONFIG_PARAM_MAX_FAILOVER_ATTEMPTS);
          builder.append(HaServiceConfigConstants.CONFIG_PAIR_DELIMITER);
-         builder.append(String.valueOf(maxFailoverAttempts));
+         builder.append(maxFailoverAttempts);
       }
 
       if (failoverSleep > -1) {
          builder.append(HaServiceConfigConstants.CONFIG_PAIRS_DELIMITER);
          builder.append(HaServiceConfigConstants.CONFIG_PARAM_FAILOVER_SLEEP);
          builder.append(HaServiceConfigConstants.CONFIG_PAIR_DELIMITER);
-         builder.append(String.valueOf(failoverSleep));
+         builder.append(failoverSleep);
       }
 
       if (zooKeeperNamespace != null) {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/DefaultHaProviderTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/DefaultHaProviderTest.java b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/DefaultHaProviderTest.java
index 27491c5..b5b2a3f 100644
--- a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/DefaultHaProviderTest.java
+++ b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/DefaultHaProviderTest.java
@@ -39,6 +39,7 @@ public class DefaultHaProviderTest {
          new DefaultHaProvider(null);
          fail("provider construction should have failed with null descriptor");
       } catch (IllegalArgumentException e) {
+        // Expected exception
       }
       HaDescriptor descriptor = new DefaultHaDescriptor();
       HaProvider provider = new DefaultHaProvider(descriptor);

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-identity-assertion-common/src/main/java/org/apache/knox/gateway/identityasserter/common/filter/AbstractIdentityAssertionFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-identity-assertion-common/src/main/java/org/apache/knox/gateway/identityasserter/common/filter/AbstractIdentityAssertionFilter.java b/gateway-provider-identity-assertion-common/src/main/java/org/apache/knox/gateway/identityasserter/common/filter/AbstractIdentityAssertionFilter.java
index f6dbae6..c210128 100644
--- a/gateway-provider-identity-assertion-common/src/main/java/org/apache/knox/gateway/identityasserter/common/filter/AbstractIdentityAssertionFilter.java
+++ b/gateway-provider-identity-assertion-common/src/main/java/org/apache/knox/gateway/identityasserter/common/filter/AbstractIdentityAssertionFilter.java
@@ -88,14 +88,14 @@ public abstract class AbstractIdentityAssertionFilter extends
   protected void continueChainAsPrincipal(HttpServletRequestWrapper request, ServletResponse response,
       FilterChain chain, String mappedPrincipalName, String[] groups) throws IOException,
       ServletException {
-        Subject subject = null;
-        Principal impersonationPrincipal = null;
-        Principal primaryPrincipal = null;
+        Subject subject;
+        Principal impersonationPrincipal;
+        Principal primaryPrincipal;
 
         // get the current subject and determine whether we need another doAs with
         // an impersonatedPrincipal and/or mapped group principals
         boolean impersonationNeeded = false;
-        boolean groupsMapped = false;
+        boolean groupsMapped;
 
         // look up the current Java Subject and assosciated group principals
         Subject currentSubject = Subject.getSubject(AccessController.getContext());
@@ -182,8 +182,8 @@ public abstract class AbstractIdentityAssertionFilter extends
       auditor.audit( Action.IDENTITY_MAPPING, mappedPrincipalName, ResourceType.PRINCIPAL,
           ActionOutcome.SUCCESS, RES.groupsList( Arrays.toString( groups ) ) );
 
-      for (int i = 0; i < groups.length; i++) {
-        subject.getPrincipals().add(new GroupPrincipal(groups[i]));
+      for (String group : groups) {
+        subject.getPrincipals().add(new GroupPrincipal(group));
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-identity-assertion-common/src/main/java/org/apache/knox/gateway/identityasserter/common/filter/CommonIdentityAssertionFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-identity-assertion-common/src/main/java/org/apache/knox/gateway/identityasserter/common/filter/CommonIdentityAssertionFilter.java b/gateway-provider-identity-assertion-common/src/main/java/org/apache/knox/gateway/identityasserter/common/filter/CommonIdentityAssertionFilter.java
index db75424..9e9987b 100644
--- a/gateway-provider-identity-assertion-common/src/main/java/org/apache/knox/gateway/identityasserter/common/filter/CommonIdentityAssertionFilter.java
+++ b/gateway-provider-identity-assertion-common/src/main/java/org/apache/knox/gateway/identityasserter/common/filter/CommonIdentityAssertionFilter.java
@@ -107,11 +107,9 @@ public class CommonIdentityAssertionFilter extends AbstractIdentityAssertionFilt
       ServletRequest request, String mappedPrincipalName) {
     // wrap the request so that the proper principal is returned
     // from request methods
-    IdentityAsserterHttpServletRequestWrapper wrapper =
-        new IdentityAsserterHttpServletRequestWrapper(
-        (HttpServletRequest)request,
+    return new IdentityAsserterHttpServletRequestWrapper(
+        (HttpServletRequest) request,
         mappedPrincipalName);
-    return wrapper;
   }
 
   protected String[] mapGroupPrincipalsBase(String mappedPrincipalName, Subject subject) {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-identity-assertion-common/src/main/java/org/apache/knox/gateway/identityasserter/common/filter/IdentityAsserterHttpServletRequestWrapper.java
----------------------------------------------------------------------
diff --git a/gateway-provider-identity-assertion-common/src/main/java/org/apache/knox/gateway/identityasserter/common/filter/IdentityAsserterHttpServletRequestWrapper.java b/gateway-provider-identity-assertion-common/src/main/java/org/apache/knox/gateway/identityasserter/common/filter/IdentityAsserterHttpServletRequestWrapper.java
index b4395d8..71251ca 100644
--- a/gateway-provider-identity-assertion-common/src/main/java/org/apache/knox/gateway/identityasserter/common/filter/IdentityAsserterHttpServletRequestWrapper.java
+++ b/gateway-provider-identity-assertion-common/src/main/java/org/apache/knox/gateway/identityasserter/common/filter/IdentityAsserterHttpServletRequestWrapper.java
@@ -129,9 +129,9 @@ private static SpiGatewayMessages log = MessagesFactory.get( SpiGatewayMessages.
 
   private Map<String, List<String>> getParams( String qString )
       throws UnsupportedEncodingException {
-    Map<String, List<String>> params = null;
+    Map<String, List<String>> params;
     if (getMethod().equals("GET")) {
-      if (qString != null && qString.length() > 0) {
+      if (qString != null && !qString.isEmpty()) {
         params = HttpUtils.splitQuery( qString );
       }
       else {
@@ -139,7 +139,7 @@ private static SpiGatewayMessages log = MessagesFactory.get( SpiGatewayMessages.
       }
     }
     else {
-      if (qString == null || qString.length() == 0) {
+      if (qString == null || qString.isEmpty()) {
         return null;
       }
       else {
@@ -259,7 +259,7 @@ private static SpiGatewayMessages log = MessagesFactory.get( SpiGatewayMessages.
     StringBuilder sb = new StringBuilder();
     for( Map.Entry<String,List<String>> entry : map.entrySet() ) {
       String name = entry.getKey();
-      if( name != null && name.length() > 0 ) {
+      if( name != null && !name.isEmpty()) {
         List<String> values = entry.getValue();
         if( values == null || values.isEmpty() ) {
           sb.append( entry.getKey() );

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/filter/IdentityAssertionHttpServletRequestWrapperTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/filter/IdentityAssertionHttpServletRequestWrapperTest.java b/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/filter/IdentityAssertionHttpServletRequestWrapperTest.java
index 7290e0d..4ff9efb 100644
--- a/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/filter/IdentityAssertionHttpServletRequestWrapperTest.java
+++ b/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/filter/IdentityAssertionHttpServletRequestWrapperTest.java
@@ -257,7 +257,7 @@ public class IdentityAssertionHttpServletRequestWrapperTest {
     assertThat( s, is( "null-values" ) );
 
     m = new HashMap<>();
-    m.put( "no-values", new ArrayList<String>(0) );
+    m.put( "no-values", new ArrayList<>(0) );
     s = IdentityAsserterHttpServletRequestWrapper.urlEncode( m, StandardCharsets.UTF_8.name() );
     assertThat( s, is( "no-values" ) );
 

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/function/UsernameFunctionDescriptorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/function/UsernameFunctionDescriptorTest.java b/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/function/UsernameFunctionDescriptorTest.java
index 1af3a43..b6f699b 100644
--- a/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/function/UsernameFunctionDescriptorTest.java
+++ b/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/function/UsernameFunctionDescriptorTest.java
@@ -21,7 +21,6 @@ import org.apache.knox.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
 import org.apache.knox.gateway.identityasserter.common.function.UsernameFunctionDescriptor;
 import org.junit.Test;
 
-import java.util.Iterator;
 import java.util.ServiceLoader;
 
 import static org.hamcrest.CoreMatchers.is;
@@ -39,10 +38,8 @@ public class UsernameFunctionDescriptorTest {
   @Test
   public void testServiceLoader() throws Exception {
     ServiceLoader loader = ServiceLoader.load( UrlRewriteFunctionDescriptor.class );
-    Iterator iterator = loader.iterator();
-    while( iterator.hasNext() ) {
-      Object object = iterator.next();
-      if( object instanceof UsernameFunctionDescriptor ) {
+    for (Object object : loader) {
+      if (object instanceof UsernameFunctionDescriptor) {
         return;
       }
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/function/UsernameFunctionProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/function/UsernameFunctionProcessorTest.java b/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/function/UsernameFunctionProcessorTest.java
index 785751f..3d9876b 100644
--- a/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/function/UsernameFunctionProcessorTest.java
+++ b/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/function/UsernameFunctionProcessorTest.java
@@ -54,10 +54,9 @@ import java.nio.charset.StandardCharsets;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.util.ArrayDeque;
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.EnumSet;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Queue;
 import java.util.ServiceLoader;
@@ -77,8 +76,7 @@ public class UsernameFunctionProcessorTest {
 
   private static URL getTestResource( String name ) {
     name = UsernameFunctionProcessorTest.class.getName().replaceAll( "\\.", "/" ) + "/" + name;
-    URL url = ClassLoader.getSystemResource( name );
-    return url;
+    return ClassLoader.getSystemResource( name );
   }
 
   public void setUp( String username, Map<String,String> initParams ) throws Exception {
@@ -139,7 +137,7 @@ public class UsernameFunctionProcessorTest {
   public void testResolve() throws Exception {
     final UsernameFunctionProcessor processor = new UsernameFunctionProcessor();
     assertThat( processor.resolve( null, null ), nullValue() );
-    assertThat( processor.resolve( null, Arrays.asList( "test-input" ) ), contains( "test-input" ) );
+    assertThat( processor.resolve( null, Collections.singletonList("test-input")), contains( "test-input" ) );
     Subject subject = new Subject();
     subject.getPrincipals().add( new PrimaryPrincipal( "test-username" ) );
     subject.setReadOnly();
@@ -147,7 +145,7 @@ public class UsernameFunctionProcessorTest {
       @Override
       public Object run() throws Exception {
         assertThat( processor.resolve( null, null ), contains( "test-username" ) );
-        assertThat( processor.resolve( null, Arrays.asList( "test-ignored" ) ), contains( "test-username" ) );
+        assertThat( processor.resolve( null, Collections.singletonList("test-ignored")), contains( "test-username" ) );
         return null;
       }
     } );
@@ -156,10 +154,8 @@ public class UsernameFunctionProcessorTest {
   @Test
   public void testServiceLoader() throws Exception {
     ServiceLoader loader = ServiceLoader.load( UrlRewriteFunctionProcessor.class );
-    Iterator iterator = loader.iterator();
-    while( iterator.hasNext() ) {
-      Object object = iterator.next();
-      if( object instanceof UsernameFunctionProcessor ) {
+    for (Object object : loader) {
+      if (object instanceof UsernameFunctionProcessor) {
         return;
       }
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/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 391f4a4..95026a3 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
@@ -94,7 +94,7 @@ public class HadoopGroupProviderFilter extends CommonIdentityAssertionFilter {
   public String[] mapGroupPrincipals(final String mappedPrincipalName,
                                      final Subject subject) {
     /* return the groups as seen by Hadoop */
-    String[] groups = null;
+    String[] groups;
     try {
       final List<String> groupList = hadoopGroups
           .getGroups(mappedPrincipalName);

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-identity-assertion-pseudo/src/test/java/org/apache/knox/gateway/identityasserter/filter/DefaultIdentityAssertionFilterTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-identity-assertion-pseudo/src/test/java/org/apache/knox/gateway/identityasserter/filter/DefaultIdentityAssertionFilterTest.java b/gateway-provider-identity-assertion-pseudo/src/test/java/org/apache/knox/gateway/identityasserter/filter/DefaultIdentityAssertionFilterTest.java
index 273c103..72d4606 100644
--- a/gateway-provider-identity-assertion-pseudo/src/test/java/org/apache/knox/gateway/identityasserter/filter/DefaultIdentityAssertionFilterTest.java
+++ b/gateway-provider-identity-assertion-pseudo/src/test/java/org/apache/knox/gateway/identityasserter/filter/DefaultIdentityAssertionFilterTest.java
@@ -93,8 +93,8 @@ public class DefaultIdentityAssertionFilterTest {
 
   private boolean groupFoundIn(String expected, String[] mappedGroups) {
     if (mappedGroups == null) return false;
-    for(int i = 0; i < mappedGroups.length; i++) {
-      if (mappedGroups[i].equals(expected)) {
+    for (String mappedGroup : mappedGroups) {
+      if (mappedGroup.equals(expected)) {
         return true;
       }
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite-func-hostmap-static/src/main/java/org/apache/knox/gateway/hostmap/impl/HostmapDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-hostmap-static/src/main/java/org/apache/knox/gateway/hostmap/impl/HostmapDeploymentContributor.java b/gateway-provider-rewrite-func-hostmap-static/src/main/java/org/apache/knox/gateway/hostmap/impl/HostmapDeploymentContributor.java
index adcbbcf..b4d7fee 100644
--- a/gateway-provider-rewrite-func-hostmap-static/src/main/java/org/apache/knox/gateway/hostmap/impl/HostmapDeploymentContributor.java
+++ b/gateway-provider-rewrite-func-hostmap-static/src/main/java/org/apache/knox/gateway/hostmap/impl/HostmapDeploymentContributor.java
@@ -82,8 +82,7 @@ public class HostmapDeploymentContributor
     }
     writer.close();
     String string = buffer.toString();
-    Asset asset = new StringAsset( string );
-    return asset;
+    return new StringAsset( string );
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite-func-hostmap-static/src/test/java/org/apache/knox/gateway/hostmap/impl/HostmapFunctionProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-hostmap-static/src/test/java/org/apache/knox/gateway/hostmap/impl/HostmapFunctionProcessorTest.java b/gateway-provider-rewrite-func-hostmap-static/src/test/java/org/apache/knox/gateway/hostmap/impl/HostmapFunctionProcessorTest.java
index e405ae4..6eee0b3 100644
--- a/gateway-provider-rewrite-func-hostmap-static/src/test/java/org/apache/knox/gateway/hostmap/impl/HostmapFunctionProcessorTest.java
+++ b/gateway-provider-rewrite-func-hostmap-static/src/test/java/org/apache/knox/gateway/hostmap/impl/HostmapFunctionProcessorTest.java
@@ -36,7 +36,7 @@ import org.easymock.EasyMock;
 import org.junit.Test;
 
 import java.net.URL;
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.ServiceLoader;
 
@@ -75,10 +75,10 @@ public class HostmapFunctionProcessorTest {
 
     UrlRewriteEnvironment environment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
     EasyMock.expect( environment.getAttribute( GatewayServices.GATEWAY_SERVICES_ATTRIBUTE ) ).andReturn( gatewayServices ).anyTimes();
-    EasyMock.expect( environment.resolve( "cluster.name" ) ).andReturn( Arrays.asList( "test-cluster-name" ) ).anyTimes();
+    EasyMock.expect( environment.resolve( "cluster.name" ) ).andReturn(Collections.singletonList("test-cluster-name")).anyTimes();
     EasyMock.expect( environment.getResource( "/WEB-INF/hostmap.txt" ) ).andReturn( configUrl ).anyTimes();
     Resolver resolver = EasyMock.createNiceMock( Resolver.class );
-    EasyMock.expect( resolver.resolve( "host" ) ).andReturn( Arrays.asList( "test-inbound-host" ) ).anyTimes();
+    EasyMock.expect( resolver.resolve( "host" ) ).andReturn(Collections.singletonList("test-inbound-host")).anyTimes();
     EasyMock.replay( gatewayServices, hm, hms, environment, resolver );
 
     UrlRewriteRulesDescriptor descriptor = UrlRewriteRulesDescriptorFactory.create();
@@ -104,7 +104,7 @@ public class HostmapFunctionProcessorTest {
     UrlRewriteEnvironment environment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
     EasyMock.expect( environment.getResource( "/WEB-INF/hostmap.txt" ) ).andReturn( configUrl ).anyTimes();
     Resolver resolver = EasyMock.createNiceMock( Resolver.class );
-    EasyMock.expect( resolver.resolve( "host" ) ).andReturn( Arrays.asList( "test-internal-host" ) ).anyTimes();
+    EasyMock.expect( resolver.resolve( "host" ) ).andReturn(Collections.singletonList("test-internal-host")).anyTimes();
     EasyMock.replay( environment, resolver );
 
     UrlRewriteRulesDescriptor descriptor = UrlRewriteRulesDescriptorFactory.create();
@@ -138,7 +138,7 @@ public class HostmapFunctionProcessorTest {
     UrlRewriteEnvironment environment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
     EasyMock.expect( environment.getResource( "/WEB-INF/hostmap.txt" ) ).andReturn( configUrl ).anyTimes();
     Resolver resolver = EasyMock.createNiceMock( Resolver.class );
-    EasyMock.expect( resolver.resolve( "host" ) ).andReturn( Arrays.asList( "test-internal-host" ) ).anyTimes();
+    EasyMock.expect( resolver.resolve( "host" ) ).andReturn(Collections.singletonList("test-internal-host")).anyTimes();
     EasyMock.replay( environment, resolver );
 
     UrlRewriteRulesDescriptor descriptor = UrlRewriteRulesDescriptorFactory.create();
@@ -172,7 +172,7 @@ public class HostmapFunctionProcessorTest {
     UrlRewriteEnvironment environment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
     EasyMock.expect( environment.getResource( "/WEB-INF/hostmap.txt" ) ).andReturn( configUrl ).anyTimes();
     Resolver resolver = EasyMock.createNiceMock( Resolver.class );
-    EasyMock.expect( resolver.resolve( "host" ) ).andReturn( Arrays.asList( "test-inbound-unmapped-host" ) ).anyTimes();
+    EasyMock.expect( resolver.resolve( "host" ) ).andReturn(Collections.singletonList("test-inbound-unmapped-host")).anyTimes();
     EasyMock.replay( environment, resolver );
 
     UrlRewriteRulesDescriptor descriptor = UrlRewriteRulesDescriptorFactory.create();
@@ -199,7 +199,7 @@ public class HostmapFunctionProcessorTest {
     UrlRewriteEnvironment environment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
     EasyMock.expect( environment.getResource( "/WEB-INF/hostmap.txt" ) ).andReturn( configUrl ).anyTimes();
     Resolver resolver = EasyMock.createNiceMock( Resolver.class );
-    EasyMock.expect( resolver.resolve( "host" ) ).andReturn( Arrays.asList( "test-inbound-host" ) ).anyTimes();
+    EasyMock.expect( resolver.resolve( "host" ) ).andReturn(Collections.singletonList("test-inbound-host")).anyTimes();
     EasyMock.replay( environment, resolver );
 
     UrlRewriteRulesDescriptor descriptor = UrlRewriteRulesDescriptorFactory.create();
@@ -225,7 +225,7 @@ public class HostmapFunctionProcessorTest {
     UrlRewriteEnvironment environment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
     EasyMock.expect( environment.getResource( "/WEB-INF/hostmap.txt" ) ).andReturn( configUrl ).anyTimes();
     Resolver resolver = EasyMock.createNiceMock( Resolver.class );
-    EasyMock.expect( resolver.resolve( "host" ) ).andReturn( Arrays.asList( "test-inbound-host" ) ).anyTimes();
+    EasyMock.expect( resolver.resolve( "host" ) ).andReturn(Collections.singletonList("test-inbound-host")).anyTimes();
     EasyMock.replay( environment, resolver );
 
     UrlRewriteRulesDescriptor descriptor = UrlRewriteRulesDescriptorFactory.create();
@@ -251,7 +251,7 @@ public class HostmapFunctionProcessorTest {
     UrlRewriteEnvironment environment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
     EasyMock.expect( environment.getResource( "/WEB-INF/hostmap.txt" ) ).andReturn( configUrl ).anyTimes();
     Resolver resolver = EasyMock.createNiceMock( Resolver.class );
-    EasyMock.expect( resolver.resolve( "host" ) ).andReturn( Arrays.asList( "test-inbound-host" ) ).anyTimes();
+    EasyMock.expect( resolver.resolve( "host" ) ).andReturn(Collections.singletonList("test-inbound-host")).anyTimes();
     EasyMock.replay( environment, resolver );
 
     UrlRewriteRulesDescriptor descriptor = UrlRewriteRulesDescriptorFactory.create();

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite-func-inbound-query-param/src/main/java/org/apache/knox/gateway/inboundurl/impl/InboundUrlFunctionProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-inbound-query-param/src/main/java/org/apache/knox/gateway/inboundurl/impl/InboundUrlFunctionProcessor.java b/gateway-provider-rewrite-func-inbound-query-param/src/main/java/org/apache/knox/gateway/inboundurl/impl/InboundUrlFunctionProcessor.java
index 2fe2adf..bd7f987 100644
--- a/gateway-provider-rewrite-func-inbound-query-param/src/main/java/org/apache/knox/gateway/inboundurl/impl/InboundUrlFunctionProcessor.java
+++ b/gateway-provider-rewrite-func-inbound-query-param/src/main/java/org/apache/knox/gateway/inboundurl/impl/InboundUrlFunctionProcessor.java
@@ -44,7 +44,7 @@ public class InboundUrlFunctionProcessor
 
   @Override
   public List<String> resolve( UrlRewriteContext context, List<String> parameters ) throws Exception {
-      if( parameters == null || parameters.size() == 0 ) {
+      if( parameters == null || parameters.isEmpty()) {
         return Collections.emptyList();
       } else {
         switch( context.getDirection() ) {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceAddressFunctionProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceAddressFunctionProcessorTest.java b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceAddressFunctionProcessorTest.java
index 5981437..9851b82 100644
--- a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceAddressFunctionProcessorTest.java
+++ b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceAddressFunctionProcessorTest.java
@@ -29,7 +29,7 @@ import org.easymock.EasyMock;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.ServiceLoader;
 
@@ -133,8 +133,8 @@ public class ServiceAddressFunctionProcessorTest {
     ServiceAddressFunctionProcessor func = new ServiceAddressFunctionProcessor();
     func.initialize( env, desc );
 
-    assertThat( func.resolve( ctx, Arrays.asList( "test-service" ) ), contains( "test-host:777" ) );
-    assertThat( func.resolve( ctx, Arrays.asList( "invalid-test-service" ) ), contains( "invalid-test-service" ) );
+    assertThat( func.resolve( ctx, Collections.singletonList("test-service")), contains( "test-host:777" ) );
+    assertThat( func.resolve( ctx, Collections.singletonList("invalid-test-service")), contains( "invalid-test-service" ) );
     assertThat( func.resolve( ctx, null ), nullValue() );
 
     func.destroy();

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceHostFunctionProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceHostFunctionProcessorTest.java b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceHostFunctionProcessorTest.java
index 46f4063..042792e 100644
--- a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceHostFunctionProcessorTest.java
+++ b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceHostFunctionProcessorTest.java
@@ -29,7 +29,7 @@ import org.easymock.EasyMock;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.ServiceLoader;
 
@@ -134,8 +134,8 @@ public class ServiceHostFunctionProcessorTest {
     ServiceHostFunctionProcessor func = new ServiceHostFunctionProcessor();
     func.initialize( env, desc );
 
-    assertThat( func.resolve( ctx, Arrays.asList( "test-service" ) ), contains( "test-host" ) );
-    assertThat( func.resolve( ctx, Arrays.asList( "invalid-test-service" ) ), contains( "invalid-test-service" ) );
+    assertThat( func.resolve( ctx, Collections.singletonList("test-service")), contains( "test-host" ) );
+    assertThat( func.resolve( ctx, Collections.singletonList("invalid-test-service")), contains( "invalid-test-service" ) );
     assertThat( func.resolve( ctx, null ), nullValue() );
 
     func.destroy();

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceMappedAddressFunctionProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceMappedAddressFunctionProcessorTest.java b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceMappedAddressFunctionProcessorTest.java
index 11384fe..62a39a8 100644
--- a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceMappedAddressFunctionProcessorTest.java
+++ b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceMappedAddressFunctionProcessorTest.java
@@ -32,7 +32,7 @@ import org.easymock.EasyMock;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.ServiceLoader;
 
@@ -146,8 +146,8 @@ public class ServiceMappedAddressFunctionProcessorTest {
     ServiceMappedAddressFunctionProcessor func = new ServiceMappedAddressFunctionProcessor();
     func.initialize( env, desc );
 
-    assertThat( func.resolve( ctx, Arrays.asList( "test-service" ) ), contains( "test-internal-host:777" ) );
-    assertThat( func.resolve( ctx, Arrays.asList( "invalid-test-service" ) ), contains( "invalid-test-service" ) );
+    assertThat( func.resolve( ctx, Collections.singletonList("test-service")), contains( "test-internal-host:777" ) );
+    assertThat( func.resolve( ctx, Collections.singletonList("invalid-test-service")), contains( "invalid-test-service" ) );
     assertThat( func.resolve( ctx, null ), nullValue() );
 
     func.destroy();

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceMappedHostFunctionProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceMappedHostFunctionProcessorTest.java b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceMappedHostFunctionProcessorTest.java
index 1b79f9b..4b869f5 100644
--- a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceMappedHostFunctionProcessorTest.java
+++ b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceMappedHostFunctionProcessorTest.java
@@ -32,7 +32,7 @@ import org.easymock.EasyMock;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.ServiceLoader;
 
@@ -146,8 +146,8 @@ public class ServiceMappedHostFunctionProcessorTest {
     ServiceMappedHostFunctionProcessor func = new ServiceMappedHostFunctionProcessor();
     func.initialize( env, desc );
 
-    assertThat( func.resolve( ctx, Arrays.asList( "test-service" ) ), contains( "test-internal-host" ) );
-    assertThat( func.resolve( ctx, Arrays.asList( "invalid-test-service" ) ), contains( "invalid-test-service" ) );
+    assertThat( func.resolve( ctx, Collections.singletonList("test-service")), contains( "test-internal-host" ) );
+    assertThat( func.resolve( ctx, Collections.singletonList("invalid-test-service")), contains( "invalid-test-service" ) );
     assertThat( func.resolve( ctx, null ), nullValue() );
 
     func.destroy();

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceMappedUrlFunctionProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceMappedUrlFunctionProcessorTest.java b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceMappedUrlFunctionProcessorTest.java
index 5fc6546..dd978bd 100644
--- a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceMappedUrlFunctionProcessorTest.java
+++ b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceMappedUrlFunctionProcessorTest.java
@@ -32,7 +32,7 @@ import org.easymock.EasyMock;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.ServiceLoader;
 
@@ -147,8 +147,8 @@ public class ServiceMappedUrlFunctionProcessorTest {
     ServiceMappedUrlFunctionProcessor func = new ServiceMappedUrlFunctionProcessor();
     func.initialize( env, desc );
 
-    assertThat( func.resolve( ctx, Arrays.asList( "test-service" ) ), contains( "test-scheme://test-internal-host:777/test-path" ) );
-    assertThat( func.resolve( ctx, Arrays.asList( "invalid-test-service" ) ), contains( "invalid-test-service" ) );
+    assertThat( func.resolve( ctx, Collections.singletonList("test-service")), contains( "test-scheme://test-internal-host:777/test-path" ) );
+    assertThat( func.resolve( ctx, Collections.singletonList("invalid-test-service")), contains( "invalid-test-service" ) );
     assertThat( func.resolve( ctx, null ), nullValue() );
 
     func.destroy();

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServicePathFunctionProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServicePathFunctionProcessorTest.java b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServicePathFunctionProcessorTest.java
index a66bcf0..0a96d99 100644
--- a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServicePathFunctionProcessorTest.java
+++ b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServicePathFunctionProcessorTest.java
@@ -29,7 +29,7 @@ import org.easymock.EasyMock;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.ServiceLoader;
 
@@ -134,7 +134,7 @@ public class ServicePathFunctionProcessorTest {
     func.initialize( env, desc );
 
 //    assertThat( func.resolve( ctx, "test-service" ), is( "/test-path" ) );
-    assertThat( func.resolve( ctx, Arrays.asList( "invalid-test-service" ) ), contains( "invalid-test-service" ) );
+    assertThat( func.resolve( ctx, Collections.singletonList("invalid-test-service")), contains( "invalid-test-service" ) );
 //    assertThat( func.resolve( ctx, null ), nullValue() );
 
     func.destroy();

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServicePortFunctionProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServicePortFunctionProcessorTest.java b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServicePortFunctionProcessorTest.java
index 7b25957..d9b6d1f 100644
--- a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServicePortFunctionProcessorTest.java
+++ b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServicePortFunctionProcessorTest.java
@@ -29,7 +29,7 @@ import org.easymock.EasyMock;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.ServiceLoader;
 
@@ -133,8 +133,8 @@ public class ServicePortFunctionProcessorTest {
     ServicePortFunctionProcessor func = new ServicePortFunctionProcessor();
     func.initialize( env, desc );
 
-    assertThat( func.resolve( ctx, Arrays.asList( "test-service" ) ), contains( "777" ) );
-    assertThat( func.resolve( ctx, Arrays.asList( "invalid-test-service" ) ), contains( "invalid-test-service" ) );
+    assertThat( func.resolve( ctx, Collections.singletonList("test-service")), contains( "777" ) );
+    assertThat( func.resolve( ctx, Collections.singletonList("invalid-test-service")), contains( "invalid-test-service" ) );
     assertThat( func.resolve( ctx, null ), nullValue() );
 
     func.destroy();

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceRegistryFunctionsTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceRegistryFunctionsTest.java b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceRegistryFunctionsTest.java
index 081eeeb..b014589 100644
--- a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceRegistryFunctionsTest.java
+++ b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceRegistryFunctionsTest.java
@@ -71,8 +71,7 @@ public class ServiceRegistryFunctionsTest {
 
   private static URL getTestResource( String name ) {
     name = ServiceRegistryFunctionsTest.class.getName().replaceAll( "\\.", "/" ) + "/" + name;
-    URL url = ClassLoader.getSystemResource( name );
-    return url;
+    return ClassLoader.getSystemResource( name );
   }
 
   public void setUp( String username, Map<String,String> initParams ) throws Exception {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceSchemeFunctionProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceSchemeFunctionProcessorTest.java b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceSchemeFunctionProcessorTest.java
index 49c9872..0aad5eb 100644
--- a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceSchemeFunctionProcessorTest.java
+++ b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceSchemeFunctionProcessorTest.java
@@ -29,7 +29,7 @@ import org.easymock.EasyMock;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.ServiceLoader;
 
@@ -133,8 +133,8 @@ public class ServiceSchemeFunctionProcessorTest {
     ServiceSchemeFunctionProcessor func = new ServiceSchemeFunctionProcessor();
     func.initialize( env, desc );
 
-    assertThat( func.resolve( ctx, Arrays.asList( "test-service" ) ), contains( "test-scheme" ) );
-    assertThat( func.resolve( ctx, Arrays.asList( "invalid-test-service" ) ), contains( "invalid-test-service" ) );
+    assertThat( func.resolve( ctx, Collections.singletonList("test-service")), contains( "test-scheme" ) );
+    assertThat( func.resolve( ctx, Collections.singletonList("invalid-test-service")), contains( "invalid-test-service" ) );
     assertThat( func.resolve( ctx, null ), nullValue() );
 
     func.destroy();

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceUrlFunctionProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceUrlFunctionProcessorTest.java b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceUrlFunctionProcessorTest.java
index ad146ca..8a8d05b 100644
--- a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceUrlFunctionProcessorTest.java
+++ b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceUrlFunctionProcessorTest.java
@@ -32,7 +32,7 @@ import org.easymock.EasyMock;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.ServiceLoader;
 
@@ -146,8 +146,8 @@ public class ServiceUrlFunctionProcessorTest {
     ServiceUrlFunctionProcessor func = new ServiceUrlFunctionProcessor();
     func.initialize( env, desc );
 
-    assertThat( func.resolve( ctx, Arrays.asList( "test-service" ) ), contains( "test-scheme://test-host:777/test-path" ) );
-    assertThat( func.resolve( ctx, Arrays.asList( "invalid-test-service" ) ), contains( "invalid-test-service" ) );
+    assertThat( func.resolve( ctx, Collections.singletonList("test-service")), contains( "test-scheme://test-host:777/test-path" ) );
+    assertThat( func.resolve( ctx, Collections.singletonList("invalid-test-service")), contains( "invalid-test-service" ) );
     assertThat( func.resolve( ctx, null ), nullValue() );
 
     func.destroy();

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite-step-encrypt-uri/src/main/java/org/apache/knox/gateway/encrypturi/impl/EncryptUriProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-step-encrypt-uri/src/main/java/org/apache/knox/gateway/encrypturi/impl/EncryptUriProcessor.java b/gateway-provider-rewrite-step-encrypt-uri/src/main/java/org/apache/knox/gateway/encrypturi/impl/EncryptUriProcessor.java
index 959c27b..ee9ca85 100644
--- a/gateway-provider-rewrite-step-encrypt-uri/src/main/java/org/apache/knox/gateway/encrypturi/impl/EncryptUriProcessor.java
+++ b/gateway-provider-rewrite-step-encrypt-uri/src/main/java/org/apache/knox/gateway/encrypturi/impl/EncryptUriProcessor.java
@@ -19,7 +19,7 @@ package org.apache.knox.gateway.encrypturi.impl;
 
 import java.io.UnsupportedEncodingException;
 import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
+import java.util.Collections;
 
 import org.apache.commons.codec.binary.Base64;
 import org.apache.knox.gateway.encrypturi.EncryptStepContextParams;
@@ -66,7 +66,7 @@ public class EncryptUriProcessor
       if( resolvedTemplate != null && !resolvedTemplate.isEmpty() ) {
         String endcoedUrl = encode( resolvedTemplate );
         EncryptStepContextParams params = new EncryptStepContextParams();
-        params.addParam( param, Arrays.asList( endcoedUrl ) );
+        params.addParam( param, Collections.singletonList(endcoedUrl));
         context.addParameters( params );
         return UrlRewriteStepStatus.SUCCESS;
       }


Mime
View raw message