knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kris...@apache.org
Subject [4/5] knox git commit: KNOX-1664 - Miscellaneous code cleanup
Date Sat, 08 Dec 2018 14:29:57 GMT
http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite-step-encrypt-uri/src/test/java/org/apache/knox/gateway/encrypturi/impl/EncryptDecryptUriProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-step-encrypt-uri/src/test/java/org/apache/knox/gateway/encrypturi/impl/EncryptDecryptUriProcessorTest.java b/gateway-provider-rewrite-step-encrypt-uri/src/test/java/org/apache/knox/gateway/encrypturi/impl/EncryptDecryptUriProcessorTest.java
index 2ee3c22..89bf8ea 100644
--- a/gateway-provider-rewrite-step-encrypt-uri/src/test/java/org/apache/knox/gateway/encrypturi/impl/EncryptDecryptUriProcessorTest.java
+++ b/gateway-provider-rewrite-step-encrypt-uri/src/test/java/org/apache/knox/gateway/encrypturi/impl/EncryptDecryptUriProcessorTest.java
@@ -31,7 +31,7 @@ import org.easymock.Capture;
 import org.easymock.EasyMock;
 import org.junit.Test;
 
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.ServiceLoader;
 
@@ -93,8 +93,8 @@ public class EncryptDecryptUriProcessorTest {
     UrlRewriteContext encContext = EasyMock.createNiceMock( UrlRewriteContext.class );
 
     EncryptStepContextParams hostPortParams = new EncryptStepContextParams();
-    hostPortParams.addParam( "host", Arrays.asList( "host.yarn.com" ) );
-    hostPortParams.addParam( "port", Arrays.asList( "8088" ) );
+    hostPortParams.addParam( "host", Collections.singletonList("host.yarn.com"));
+    hostPortParams.addParam( "port", Collections.singletonList("8088"));
     EasyMock.expect( encContext.getParameters() ).andReturn( hostPortParams );
 
 
@@ -131,8 +131,8 @@ public class EncryptDecryptUriProcessorTest {
     UrlRewriteContext decContext = EasyMock.createNiceMock( UrlRewriteContext.class );
 
     EncryptStepContextParams encryptedParams = new EncryptStepContextParams();
-    encryptedParams.addParam( decParam, Arrays.asList( encryptedAdrress ) ); //Value was encrypted by EncryptUriProcessor
-    encryptedParams.addParam( "foo1", Arrays.asList( "test" ) );
+    encryptedParams.addParam( decParam, Collections.singletonList(encryptedAdrress)); //Value was encrypted by EncryptUriProcessor
+    encryptedParams.addParam( "foo1", Collections.singletonList("test"));
     EasyMock.expect( decContext.getParameters() ).andReturn( encryptedParams );
 
     Capture<EncryptStepContextParams> decodedValue = Capture.newInstance();

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite-step-secure-query/src/test/java/org/apache/knox/gateway/securequery/SecureQueryEncryptDecryptProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-step-secure-query/src/test/java/org/apache/knox/gateway/securequery/SecureQueryEncryptDecryptProcessorTest.java b/gateway-provider-rewrite-step-secure-query/src/test/java/org/apache/knox/gateway/securequery/SecureQueryEncryptDecryptProcessorTest.java
index 211f98d..9a75c27 100644
--- a/gateway-provider-rewrite-step-secure-query/src/test/java/org/apache/knox/gateway/securequery/SecureQueryEncryptDecryptProcessorTest.java
+++ b/gateway-provider-rewrite-step-secure-query/src/test/java/org/apache/knox/gateway/securequery/SecureQueryEncryptDecryptProcessorTest.java
@@ -32,7 +32,7 @@ import org.easymock.EasyMock;
 import org.junit.Test;
 import org.junit.Assert;
 
-import java.util.Arrays;
+import java.util.Collections;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
@@ -88,7 +88,7 @@ public class SecureQueryEncryptDecryptProcessorTest {
     EasyMock.expect( decEnvironment.getAttribute( GatewayServices.GATEWAY_SERVICES_ATTRIBUTE ) ).andReturn( gatewayServices ).anyTimes();
     EasyMock.expect( decEnvironment.getAttribute( GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE ) ).andReturn( "test-cluster-name" ).anyTimes();
     Params decParams = EasyMock.createNiceMock( Params.class );
-    EasyMock.expect( decParams.resolve( GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE ) ).andReturn( Arrays.asList("test-cluster-name") ).anyTimes();
+    EasyMock.expect( decParams.resolve( GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE ) ).andReturn(Collections.singletonList("test-cluster-name")).anyTimes();
     UrlRewriteContext decContext = EasyMock.createNiceMock( UrlRewriteContext.class );
     EasyMock.expect( decContext.getCurrentUrl() ).andReturn( encTemplate.getValue() );
     EasyMock.expect( decContext.getParameters() ).andReturn( decParams );
@@ -155,7 +155,7 @@ public class SecureQueryEncryptDecryptProcessorTest {
     EasyMock.expect( decEnvironment.getAttribute( GatewayServices.GATEWAY_SERVICES_ATTRIBUTE ) ).andReturn( gatewayServices ).anyTimes();
     EasyMock.expect( decEnvironment.getAttribute( GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE ) ).andReturn( "test-cluster-name" ).anyTimes();
     Params decParams = EasyMock.createNiceMock( Params.class );
-    EasyMock.expect( decParams.resolve( GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE ) ).andReturn( Arrays.asList("test-cluster-name") ).anyTimes();
+    EasyMock.expect( decParams.resolve( GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE ) ).andReturn(Collections.singletonList("test-cluster-name")).anyTimes();
     UrlRewriteContext decContext = EasyMock.createNiceMock( UrlRewriteContext.class );
     EasyMock.expect( decContext.getCurrentUrl() ).andReturn( encTemplate.getValue() );
     EasyMock.expect( decContext.getParameters() ).andReturn( decParams );

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteFunctionDescriptorFactory.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteFunctionDescriptorFactory.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteFunctionDescriptorFactory.java
index 15b81dd..507b7a7 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteFunctionDescriptorFactory.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteFunctionDescriptorFactory.java
@@ -35,9 +35,7 @@ public abstract class UrlRewriteFunctionDescriptorFactory {
     try {
       Class<? extends UrlRewriteFunctionDescriptor> descriptorClass = MAP.get( name );
       return (T)descriptorClass.newInstance();
-    } catch( InstantiationException e ) {
-      throw new IllegalArgumentException( name );
-    } catch( IllegalAccessException e ) {
+    } catch( InstantiationException | IllegalAccessException e ) {
       throw new IllegalArgumentException( name );
     }
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletContextListener.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletContextListener.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletContextListener.java
index d7eb05f..631cecc 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletContextListener.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletContextListener.java
@@ -43,7 +43,7 @@ public class UrlRewriteServletContextListener implements ServletContextListener
 
   @Override
   public void contextInitialized( ServletContextEvent event ) {
-    UrlRewriteRulesDescriptor descriptor = null;
+    UrlRewriteRulesDescriptor descriptor;
     try {
       URL url = locateDescriptor( event.getServletContext() );
       descriptor = loadDescriptor( url );

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletEnvironment.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletEnvironment.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletEnvironment.java
index cc1c125..09b5f36 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletEnvironment.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletEnvironment.java
@@ -20,7 +20,7 @@ package org.apache.knox.gateway.filter.rewrite.api;
 import javax.servlet.ServletContext;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 public class UrlRewriteServletEnvironment implements UrlRewriteEnvironment {
@@ -33,14 +33,12 @@ public class UrlRewriteServletEnvironment implements UrlRewriteEnvironment {
 
   @Override
   public URL getResource( String name ) throws MalformedURLException {
-    URL url = context.getResource( name );
-    return url;
+    return context.getResource( name );
   }
 
   @Override
   public <T> T getAttribute( String name ) {
-    T attribute = (T)context.getAttribute( name );
-    return attribute;
+    return (T)context.getAttribute( name );
   }
 
   @Override
@@ -48,7 +46,7 @@ public class UrlRewriteServletEnvironment implements UrlRewriteEnvironment {
     List<String> values = null;
     String value = context.getInitParameter( name );
     if( value != null ) {
-      values = Arrays.asList( value );
+      values = Collections.singletonList(value);
     }
     return values;
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteStepDescriptorFactory.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteStepDescriptorFactory.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteStepDescriptorFactory.java
index 5047bee..1b3d309 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteStepDescriptorFactory.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteStepDescriptorFactory.java
@@ -34,9 +34,7 @@ public abstract class UrlRewriteStepDescriptorFactory {
     try {
       Class<? extends UrlRewriteStepDescriptor> descriptorClass = MAP.get( type );
       return (T)descriptorClass.newInstance();
-    } catch( InstantiationException e ) {
-      throw new IllegalArgumentException( type );
-    } catch( IllegalAccessException e ) {
+    } catch( InstantiationException | IllegalAccessException e ) {
       throw new IllegalArgumentException( type );
     }
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/ext/ScopedMatcher.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/ext/ScopedMatcher.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/ext/ScopedMatcher.java
index 716c582..350e5c5 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/ext/ScopedMatcher.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/ext/ScopedMatcher.java
@@ -65,7 +65,7 @@ public class ScopedMatcher extends Matcher<UrlRewriteRuleProcessorHolder> {
         matches.add(match);
       }
     }
-    if (matches.size() == 0) {
+    if (matches.isEmpty()) {
       return null;
     }
     if (matches.size() == 1) {
@@ -115,7 +115,7 @@ public class ScopedMatcher extends Matcher<UrlRewriteRuleProcessorHolder> {
   private Matcher<UrlRewriteRuleProcessorHolder> getMatcher(Template template, UrlRewriteRuleProcessorHolder holder) {
     String scope = holder.getScope();
     if (!matchers.containsKey(scope)) {
-      matchers.put(scope, new Matcher<UrlRewriteRuleProcessorHolder>());
+      matchers.put(scope, new Matcher<>());
     }
 
     return matchers.get(scope);

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/FrontendFunctionProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/FrontendFunctionProcessor.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/FrontendFunctionProcessor.java
index c45a3d0..219a8cf 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/FrontendFunctionProcessor.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/FrontendFunctionProcessor.java
@@ -89,8 +89,7 @@ public class FrontendFunctionProcessor implements UrlRewriteFunctionProcessor<Fr
     if( resolver == null ) {
       throw new IllegalArgumentException( RES.invalidFrontendFunctionParameter( parameter ) );
     }
-    List<String> results = resolver.resolve( context, parameters );
-    return results;
+    return resolver.resolve( context, parameters );
   }
 
   private static class ParamResolver implements UrlRewriteResolver {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteRequest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteRequest.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteRequest.java
index f3aab7d..a369830 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteRequest.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteRequest.java
@@ -50,7 +50,7 @@ import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLDecoder;
 import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.List;
 
@@ -91,7 +91,7 @@ public class UrlRewriteRequest extends GatewayRequestWrapper implements Resolver
     Template urlTemplate;
     //KNOX-439[
     //StringBuffer urlString = super.getRequestURL();
-    StringBuffer urlString = new StringBuffer( 128 );
+    StringBuilder urlString = new StringBuilder( 128 );
     urlString.append( getScheme() );
     urlString.append( "://" );
     urlString.append( getServerName() );
@@ -185,7 +185,7 @@ public class UrlRewriteRequest extends GatewayRequestWrapper implements Resolver
 
   @Override
   public String getHeader( String name ) {
-    String value = null;
+    String value;
     if (name.equalsIgnoreCase("Host")) {
       String uri = getRequestURI();
       try {
@@ -217,7 +217,7 @@ public class UrlRewriteRequest extends GatewayRequestWrapper implements Resolver
 
   @Override
   public List<String> resolve( String name ) {
-    return Arrays.asList( config.getInitParameter( name ) );
+    return Collections.singletonList(config.getInitParameter(name));
   }
 
   private class EnumerationRewriter implements Enumeration<String> {
@@ -265,7 +265,7 @@ public class UrlRewriteRequest extends GatewayRequestWrapper implements Resolver
       UrlRewriteFilterContentDescriptor filterContentConfig = getRewriteFilterConfig( bodyFilterName, mimeType );
       if (filterContentConfig != null) {
         String asType = filterContentConfig.asType();
-        if ( asType != null && asType.trim().length() > 0 ) {
+        if ( asType != null && !asType.trim().isEmpty()) {
           mimeType = MimeTypes.create(asType, getCharacterEncoding());
         }
       }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteResponse.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteResponse.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteResponse.java
index c8516b9..783e9d5 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteResponse.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteResponse.java
@@ -153,7 +153,7 @@ public class UrlRewriteResponse extends GatewayResponseWrapper implements Params
         getRewriteFilterConfig(rewriter.getConfig(), bodyFilterName, mimeType);
     if (filterContentConfig != null) {
       String asType = filterContentConfig.asType();
-      if ( asType != null && asType.trim().length() > 0 ) {
+      if ( asType != null && !asType.trim().isEmpty()) {
         mimeType = MimeTypes.create(asType, getCharacterEncoding());
       }
     }
@@ -215,15 +215,15 @@ public class UrlRewriteResponse extends GatewayResponseWrapper implements Params
   @SuppressWarnings( "unchecked" )
   public List<String> resolve( String name ) {
     if( name.startsWith( REQUEST_PARAM_PREFIX ) ) {
-      return Arrays.asList( getRequestParam( name.substring( REQUEST_PARAM_PREFIX.length() ) ) );
+      return Collections.singletonList(getRequestParam(name.substring(REQUEST_PARAM_PREFIX.length())));
     } else if ( name.startsWith( GATEWAY_PARAM_PREFIX ) ) {
-      return Arrays.asList( getGatewayParam( name.substring( GATEWAY_PARAM_PREFIX.length() ) ) );
+      return Collections.singletonList(getGatewayParam(name.substring(GATEWAY_PARAM_PREFIX.length())));
     } else if ( name.startsWith( CLUSTER_PARAM_PREFIX ) ) {
-      return Arrays.asList( getClusterParam( name.substring( GATEWAY_PARAM_PREFIX.length() ) ) );
+      return Collections.singletonList(getClusterParam(name.substring(GATEWAY_PARAM_PREFIX.length())));
     } else if ( name.startsWith( INBOUND_QUERY_PARAM_PREFIX ) ) {
       return getInboundQueryParam(name.substring(INBOUND_QUERY_PARAM_PREFIX.length()));
     } else {
-      return Arrays.asList( config.getInitParameter( name ) );
+      return Collections.singletonList(config.getInitParameter(name));
     }
   }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteRulesDescriptorImpl.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteRulesDescriptorImpl.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteRulesDescriptorImpl.java
index 33afb45..2d31fbf 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteRulesDescriptorImpl.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteRulesDescriptorImpl.java
@@ -74,7 +74,7 @@ public class UrlRewriteRulesDescriptorImpl implements UrlRewriteRulesDescriptor
   public void addRule( UrlRewriteRuleDescriptor rule ) {
     ruleList.add( rule );
     String name = rule.name();
-    if( name != null && name.length() > 0 ) {
+    if( name != null && !name.isEmpty()) {
       ruleMap.put( rule.name(), rule );
     }
   }
@@ -87,8 +87,7 @@ public class UrlRewriteRulesDescriptorImpl implements UrlRewriteRulesDescriptor
   @Override
   @SuppressWarnings("unchecked")
   public <T extends UrlRewriteFunctionDescriptor<?>> T getFunction( String name ) {
-    T descriptor = (T)funcMap.get( name );
-    return descriptor;
+    return (T)funcMap.get( name );
   }
 
   @Override
@@ -101,8 +100,7 @@ public class UrlRewriteRulesDescriptorImpl implements UrlRewriteRulesDescriptor
 
   @SuppressWarnings("unchecked")
   protected <T extends UrlRewriteFunctionDescriptor<?>> T newFunction( String name ) {
-    T descriptor = UrlRewriteFunctionDescriptorFactory.create( name );
-    return descriptor;
+    return UrlRewriteFunctionDescriptorFactory.create( name );
   }
 
   protected void addFunction( UrlRewriteFunctionDescriptor descriptor ) {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteStepProcessorHolder.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteStepProcessorHolder.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteStepProcessorHolder.java
index 51d627f..87291f6 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteStepProcessorHolder.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteStepProcessorHolder.java
@@ -28,7 +28,6 @@ import org.apache.knox.gateway.filter.rewrite.spi.UrlRewriteStepStatus;
 import org.apache.knox.gateway.i18n.messages.MessagesFactory;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 public class UrlRewriteStepProcessorHolder implements UrlRewriteStepProcessor {
@@ -72,12 +71,10 @@ public class UrlRewriteStepProcessorHolder implements UrlRewriteStepProcessor {
       UrlRewriteFlowDescriptor flowDescriptor = (UrlRewriteFlowDescriptor)descriptor;
       List<UrlRewriteStepDescriptor> stepList = flowDescriptor.steps();
       if( stepList != null && !stepList.isEmpty() ) {
-        Iterator<UrlRewriteStepDescriptor> stepIterator = stepList.iterator();
-        while( stepIterator.hasNext() ) {
-          UrlRewriteStepDescriptor stepDescriptor = stepIterator.next();
+        for (UrlRewriteStepDescriptor stepDescriptor : stepList) {
           UrlRewriteStepProcessorHolder stepProcessor = new UrlRewriteStepProcessorHolder();
-          stepProcessor.initialize( environment, stepDescriptor );
-          childProcessors.add( stepProcessor );
+          stepProcessor.initialize(environment, stepDescriptor);
+          childProcessors.add(stepProcessor);
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteUtil.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteUtil.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteUtil.java
index c77843d..b7b665c 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteUtil.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteUtil.java
@@ -60,7 +60,7 @@ public class UrlRewriteUtil {
 
   public static String filterJavaScript( String inputValue, UrlRewriteFilterContentDescriptor config,
       UrlRewriteFilterReader filterReader, UrlRewriteFilterPathDescriptor.Compiler<Pattern> regexCompiler ) {
-    StringBuffer tbuff = new StringBuffer();
+    StringBuilder tbuff = new StringBuilder();
     StringBuffer sbuff = new StringBuffer();
     sbuff.append( inputValue );
     if( config != null && !config.getSelectors().isEmpty() ) {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/form/FormFilterReader.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/form/FormFilterReader.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/form/FormFilterReader.java
index 35ade84..76d8dd5 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/form/FormFilterReader.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/form/FormFilterReader.java
@@ -79,7 +79,7 @@ public class FormFilterReader extends Reader {
   private void processPair() throws IOException {
     FormPair pair = parser.getCurrentPair();
     String name = pair.getName();
-    String value = pair.getValue();
+    String value;
     String rule = UrlRewriteUtil.pickFirstRuleWithEqualsIgnoreCasePathMatch( config, name );
     try {
       value = filterValue( name, pair.getValue(), rule );

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlImportFunctionProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlImportFunctionProcessor.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlImportFunctionProcessor.java
index 83fa735..5687a40f 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlImportFunctionProcessor.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlImportFunctionProcessor.java
@@ -25,7 +25,7 @@ import org.apache.knox.gateway.filter.rewrite.impl.UrlRewriteFunctionProcessorFa
 import org.apache.knox.gateway.filter.rewrite.spi.UrlRewriteContext;
 import org.apache.knox.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
 
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 /**
@@ -79,7 +79,7 @@ public class HtmlImportFunctionProcessor implements UrlRewriteFunctionProcessor<
       parameters = parameters.subList(1, parameters.size());
     }
     List<String> frontendValues = frontend.resolve(context, parameters);
-    StringBuffer buffer = new StringBuffer(IMPORT_LITERAL);
+    StringBuilder buffer = new StringBuilder(IMPORT_LITERAL);
     buffer.append(" ");
     buffer.append(prefix);
     if ( frontendValues != null && !frontendValues.isEmpty() ) {
@@ -87,7 +87,7 @@ public class HtmlImportFunctionProcessor implements UrlRewriteFunctionProcessor<
         buffer.append(value);
       }
     }
-    return Arrays.asList(buffer.toString());
+    return Collections.singletonList(buffer.toString());
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlInfixProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlInfixProcessor.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlInfixProcessor.java
index f986963..f55aa43 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlInfixProcessor.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlInfixProcessor.java
@@ -24,7 +24,7 @@ import org.apache.knox.gateway.filter.rewrite.impl.UrlRewriteFunctionProcessorFa
 import org.apache.knox.gateway.filter.rewrite.spi.UrlRewriteContext;
 import org.apache.knox.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
 
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 /**
@@ -90,15 +90,15 @@ public class HtmlInfixProcessor
 
     final List<String> frontendValues = frontend.resolve(context, parameters);
 
-    final StringBuffer buffer = new StringBuffer();
+    final StringBuilder buffer = new StringBuilder();
     buffer.append(prefix);
-    if (frontendValues != null && frontendValues.size() > 0) {
+    if (frontendValues != null && !frontendValues.isEmpty()) {
       for (final String value : frontendValues) {
         buffer.append(value);
       }
     }
     buffer.append(postfix);
 
-    return Arrays.asList(buffer.toString());
+    return Collections.singletonList(buffer.toString());
   }
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlPostfixProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlPostfixProcessor.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlPostfixProcessor.java
index 4915cb6..72e3664 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlPostfixProcessor.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlPostfixProcessor.java
@@ -24,7 +24,7 @@ import org.apache.knox.gateway.filter.rewrite.impl.UrlRewriteFunctionProcessorFa
 import org.apache.knox.gateway.filter.rewrite.spi.UrlRewriteContext;
 import org.apache.knox.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
 
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 /**
@@ -90,14 +90,14 @@ public class HtmlPostfixProcessor
 
     final List<String> frontendValues = frontend.resolve(context, parameters);
 
-    final StringBuffer buffer = new StringBuffer();
-    if (frontendValues != null && frontendValues.size() > 0) {
+    final StringBuilder buffer = new StringBuilder();
+    if (frontendValues != null && !frontendValues.isEmpty()) {
       for (final String value : frontendValues) {
         buffer.append(value);
       }
     }
     buffer.append(postfix);
 
-    return Arrays.asList(buffer.toString());
+    return Collections.singletonList(buffer.toString());
   }
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlPrefixProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlPrefixProcessor.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlPrefixProcessor.java
index 303e9c2..aaf9803 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlPrefixProcessor.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/html/HtmlPrefixProcessor.java
@@ -24,7 +24,7 @@ import org.apache.knox.gateway.filter.rewrite.impl.UrlRewriteFunctionProcessorFa
 import org.apache.knox.gateway.filter.rewrite.spi.UrlRewriteContext;
 import org.apache.knox.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
 
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 /**
@@ -98,7 +98,7 @@ public class HtmlPrefixProcessor
 
     final List<String> frontendValues = frontend.resolve(context, parameters);
 
-    final StringBuffer buffer = new StringBuffer();
+    final StringBuilder buffer = new StringBuilder();
     buffer.append(prefix);
     if (frontendValues != null && !frontendValues.isEmpty()) {
       for (final String value : frontendValues) {
@@ -106,6 +106,6 @@ public class HtmlPrefixProcessor
       }
     }
 
-    return Arrays.asList(buffer.toString());
+    return Collections.singletonList(buffer.toString());
   }
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlFilterReader.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlFilterReader.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlFilterReader.java
index be67dac..379d9f0 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlFilterReader.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlFilterReader.java
@@ -125,9 +125,7 @@ public abstract class XmlFilterReader extends Reader {
         try {
           XMLEvent event = parser.nextEvent();
           processEvent( event );
-        } catch( IOException e ) {
-          throw e;
-        } catch( RuntimeException e ) {
+        } catch( IOException | RuntimeException e ) {
           throw e;
         } catch ( Exception e ) {
           throw new RuntimeException( e );
@@ -370,7 +368,7 @@ public abstract class XmlFilterReader extends Reader {
         Object node = path.evaluate( level.scopeNode, XPathConstants.NODE );
         if( node != null ) {
           UrlRewriteFilterDetectDescriptor detect = (UrlRewriteFilterDetectDescriptor)selector;
-          String value = null;
+          String value;
           if( node instanceof Element ) {
             Element element = (Element)node;
             value = element.getTextContent();

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlUrlRewriteRulesExporter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlUrlRewriteRulesExporter.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlUrlRewriteRulesExporter.java
index d6f6453..d4c8d80 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlUrlRewriteRulesExporter.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlUrlRewriteRulesExporter.java
@@ -91,17 +91,9 @@ public class XmlUrlRewriteRulesExporter implements UrlRewriteRulesExporter, XmlR
 
       XmlUtils.writeXml( document, writer );
 
-    } catch( ParserConfigurationException e ) {
+    } catch( ParserConfigurationException | TransformerException e ) {
       throw new IOException( e );
-    } catch( TransformerException e ) {
-      throw new IOException( e );
-    } catch( InvocationTargetException e ) {
-      LOG.failedToWriteRulesDescriptor( e );
-    } catch( NoSuchMethodException e ) {
-      LOG.failedToWriteRulesDescriptor( e );
-    } catch( IntrospectionException e ) {
-      LOG.failedToWriteRulesDescriptor( e );
-    } catch( IllegalAccessException e ) {
+    } catch( InvocationTargetException | IllegalAccessException | IntrospectionException | NoSuchMethodException e ) {
       LOG.failedToWriteRulesDescriptor( e );
     }
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlUrlRewriteRulesImporter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlUrlRewriteRulesImporter.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlUrlRewriteRulesImporter.java
index a061d22..0d2b68b 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlUrlRewriteRulesImporter.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlUrlRewriteRulesImporter.java
@@ -43,8 +43,7 @@ public class XmlUrlRewriteRulesImporter implements UrlRewriteRulesImporter {
     Digester digester = loader.newDigester( new ExtendedBaseRules() );
     digester.setValidating( false );
     try {
-      UrlRewriteRulesDescriptor rules = digester.parse( reader );
-      return rules;
+      return digester.parse( reader );
     } catch( SAXException e ) {
       throw new IOException( e );
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlUrlRewriteStreamFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlUrlRewriteStreamFilter.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlUrlRewriteStreamFilter.java
index 568a0f6..15e2a25 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlUrlRewriteStreamFilter.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/xml/XmlUrlRewriteStreamFilter.java
@@ -57,9 +57,7 @@ public class XmlUrlRewriteStreamFilter implements UrlRewriteStreamFilter {
       return new ReaderInputStream(
           new XmlUrlRewriteFilterReader(
               new InputStreamReader( stream, encoding ), rewriter, resolver, direction, config ), encoding );
-    } catch( ParserConfigurationException e ) {
-      throw new IOException( e );
-    } catch( XMLStreamException e ) {
+    } catch( ParserConfigurationException | XMLStreamException e ) {
       throw new IOException( e );
     }
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteProcessorTest.java b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteProcessorTest.java
index 5728cb6..3a31894 100644
--- a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteProcessorTest.java
+++ b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteProcessorTest.java
@@ -59,8 +59,7 @@ public class UrlRewriteProcessorTest {
 
   private static InputStream getTestResourceStream( String name ) throws IOException {
     URL url = getTestResourceUrl( name );
-    InputStream stream = url.openStream();
-    return stream;
+    return url.openStream();
   }
 
   private static Reader getTestResourceReader( String name ) throws IOException {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletContextListenerTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletContextListenerTest.java b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletContextListenerTest.java
index 0552b00..2c067bc 100644
--- a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletContextListenerTest.java
+++ b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletContextListenerTest.java
@@ -42,8 +42,7 @@ public class UrlRewriteServletContextListenerTest {
 
   private static URL getTestResource( String name ) {
     name = UrlRewriteServletFilterTest.class.getName().replaceAll( "\\.", "/" ) + "/" + name;
-    URL url = ClassLoader.getSystemResource( name );
-    return url;
+    return ClassLoader.getSystemResource( name );
   }
 
   @Before

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java
index 0a25a3a..df5572a 100644
--- a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java
+++ b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java
@@ -267,7 +267,7 @@ public class UrlRewriteServletFilterTest {
   public void testInboundXmlBodyRewrite() throws Exception {
     setUp( null );
     String input = "<root attribute=\"http://mock-host:1/test-input-path\">http://mock-host:1/test-input-path</root>";
-    String output = null;
+    String output;
     if(System.getProperty("java.vendor").contains("IBM")){
       output = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><root attribute=\"http://mock-host:1/test-output-path-1\">http://mock-host:1/test-output-path-1</root>";
     }else {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteContextImplTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteContextImplTest.java b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteContextImplTest.java
index 80ab1d0..9c8ae91 100644
--- a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteContextImplTest.java
+++ b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteContextImplTest.java
@@ -27,7 +27,7 @@ import org.apache.knox.gateway.util.urltemplate.Template;
 import org.easymock.EasyMock;
 import org.junit.Test;
 
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -42,10 +42,10 @@ public class UrlRewriteContextImplTest {
   public void testResolve() throws Exception {
 
     UrlRewriteEnvironment environment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
-    EasyMock.expect( environment.resolve( "test-env-param-name" ) ).andReturn( Arrays.asList( "test-env-param-value" ) ).anyTimes();
+    EasyMock.expect( environment.resolve( "test-env-param-name" ) ).andReturn(Collections.singletonList("test-env-param-value")).anyTimes();
 
     Resolver resolver = EasyMock.createNiceMock( Resolver.class );
-    EasyMock.expect( resolver.resolve( "test-ctx-param-name" ) ).andReturn( Arrays.asList( "test-ctx-param-value" ) );
+    EasyMock.expect( resolver.resolve( "test-ctx-param-name" ) ).andReturn(Collections.singletonList("test-ctx-param-value"));
 
     EasyMock.replay( environment, resolver );
 

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteResponseTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteResponseTest.java b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteResponseTest.java
index 927d22b..4d643b3 100644
--- a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteResponseTest.java
+++ b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteResponseTest.java
@@ -144,7 +144,7 @@ public class UrlRewriteResponseTest {
     File targetDir = new File( System.getProperty( "user.dir" ), "target" );
     File inputFile = new File( targetDir, "input.test" );
     File outputFile = new File( targetDir, "output.test" );
-    OutputStream outStream = null, output = null;
+    OutputStream outStream, output;
     InputStream inStream = null, input = null;
     try {
       outStream = isGzip ? new GZIPOutputStream( new FileOutputStream( inputFile ) ) : new FileOutputStream( inputFile );

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-authz-acls/src/main/java/org/apache/knox/gateway/filter/AclsAuthorizationFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-authz-acls/src/main/java/org/apache/knox/gateway/filter/AclsAuthorizationFilter.java b/gateway-provider-security-authz-acls/src/main/java/org/apache/knox/gateway/filter/AclsAuthorizationFilter.java
index 6701198..29dc38b 100644
--- a/gateway-provider-security-authz-acls/src/main/java/org/apache/knox/gateway/filter/AclsAuthorizationFilter.java
+++ b/gateway-provider-security-authz-acls/src/main/java/org/apache/knox/gateway/filter/AclsAuthorizationFilter.java
@@ -53,8 +53,8 @@ public class AclsAuthorizationFilter implements Filter {
   private String resourceRole = null;
   private String aclProcessingMode = null;
   private AclParser parser = new AclParser();
-  private ArrayList<String> adminGroups = new ArrayList<>();;
-  private ArrayList<String> adminUsers = new ArrayList<>();;
+  private ArrayList<String> adminGroups = new ArrayList<>();
+  private ArrayList<String> adminUsers = new ArrayList<>();
 
   @Override
   public void init(FilterConfig filterConfig) throws ServletException {
@@ -120,13 +120,13 @@ public class AclsAuthorizationFilter implements Filter {
 
     // before enforcing acls check whether there are no acls defined
     // which would mean that there are no restrictions
-    if (parser.users.size() == 0 && parser.groups.size() == 0 && parser.ipv.getIPAddresses().size() == 0) {
+    if (parser.users.isEmpty() && parser.groups.isEmpty() && parser.ipv.getIPAddresses().isEmpty()) {
       return true;
     }
 
-    boolean userAccess = false;
+    boolean userAccess;
     boolean groupAccess = false;
-    boolean ipAddrAccess = false;
+    boolean ipAddrAccess;
 
     Subject subject = Subject.getSubject(AccessController.getContext());
     Principal primaryPrincipal = (Principal)subject.getPrincipals(PrimaryPrincipal.class).toArray()[0];
@@ -178,7 +178,7 @@ public class AclsAuthorizationFilter implements Filter {
   }
 
   private boolean checkRemoteIpAcls(String remoteAddr) {
-    boolean allowed = false;
+    boolean allowed;
     if (remoteAddr == null) {
       return false;
     }
@@ -207,7 +207,7 @@ public class AclsAuthorizationFilter implements Filter {
   }
 
   boolean checkGroupAcls(Object[] userGroups) {
-    boolean allowed = false;
+    boolean allowed;
     if (userGroups == null) {
       return false;
     }
@@ -225,8 +225,8 @@ public class AclsAuthorizationFilter implements Filter {
 
   private boolean hasAllowedPrincipal(List<String> allowed, Object[] userGroups) {
     boolean rc = false;
-    for (int i = 0; i < userGroups.length; i++) {
-      if (allowed.contains(((Principal)userGroups[i]).getName())) {
+    for (Object userGroup : userGroups) {
+      if (allowed.contains(((Principal) userGroup).getName())) {
         rc = true;
         break;
       }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/AbstractJWTFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/AbstractJWTFilter.java b/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/AbstractJWTFilter.java
index 7639a11..2ad4c1b 100644
--- a/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/AbstractJWTFilter.java
+++ b/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/AbstractJWTFilter.java
@@ -229,8 +229,7 @@ public abstract class AbstractJWTFilter implements Filter {
     // To modify the Principals Set, the caller must have AuthPermission("modifyPrincipals").
     // To modify the public credential Set, the caller must have AuthPermission("modifyPublicCredentials").
     // To modify the private credential Set, the caller must have AuthPermission("modifyPrivateCredentials").
-    javax.security.auth.Subject subject = new javax.security.auth.Subject(true, principals, emptySet, emptySet);
-    return subject;
+    return new Subject(true, principals, emptySet, emptySet);
   }
 
   protected boolean validateToken(HttpServletRequest request, HttpServletResponse response,

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/JWTAccessTokenAssertionFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/JWTAccessTokenAssertionFilter.java b/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/JWTAccessTokenAssertionFilter.java
index 3af06be..c4de8ab 100644
--- a/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/JWTAccessTokenAssertionFilter.java
+++ b/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/JWTAccessTokenAssertionFilter.java
@@ -71,7 +71,7 @@ public class JWTAccessTokenAssertionFilter extends AbstractIdentityAssertionFilt
   @Override
   public void doFilter(ServletRequest request, ServletResponse response,
       FilterChain chain) throws IOException, ServletException {
-    String jsonResponse = null;
+    String jsonResponse;
 
     String header = ((HttpServletRequest) request).getHeader("Authorization");
     if (header != null && header.startsWith(BEARER)) {
@@ -147,7 +147,7 @@ public class JWTAccessTokenAssertionFilter extends AbstractIdentityAssertionFilt
         return principalName;
       }
     };
-    JWT token = null;
+    JWT token;
     try {
       token = authority.issueToken(p, serviceName, "RS256", expires);
       // Coverity CID 1327961

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/JWTFederationFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/JWTFederationFilter.java b/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/JWTFederationFilter.java
index 4624caa..1f40d57 100644
--- a/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/JWTFederationFilter.java
+++ b/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/JWTFederationFilter.java
@@ -75,7 +75,7 @@ public class JWTFederationFilter extends AbstractJWTFilter {
   public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
       throws IOException, ServletException {
     String header = ((HttpServletRequest) request).getHeader("Authorization");
-    String wireToken = null;
+    String wireToken;
     if (header != null && header.startsWith(BEARER)) {
       // what follows the bearer designator should be the JWT token being used to request or as an access token
       wireToken = header.substring(BEARER.length());

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/SSOCookieFederationFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/SSOCookieFederationFilter.java b/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/SSOCookieFederationFilter.java
index 05743ee..bf6ad94 100644
--- a/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/SSOCookieFederationFilter.java
+++ b/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/SSOCookieFederationFilter.java
@@ -100,7 +100,7 @@ private String gatewayPath;
   @Override
   public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
       throws IOException, ServletException {
-    String wireToken = null;
+    String wireToken;
     HttpServletRequest req = (HttpServletRequest) request;
 
     String loginURL = constructLoginURL(req);
@@ -185,10 +185,9 @@ private String gatewayPath;
     if (authenticationProviderUrl.contains("?")) {
       delimiter = "&";
     }
-    String loginURL = authenticationProviderUrl + delimiter
+    return authenticationProviderUrl + delimiter
         + ORIGINAL_URL_QUERY_PARAM
         + request.getRequestURL().append(getOriginalQueryString(request));
-    return loginURL;
   }
 
   /**
@@ -198,9 +197,9 @@ private String gatewayPath;
    * @return url that is based on KnoxSSO endpoint
    */
   public String deriveDefaultAuthenticationProviderUrl(HttpServletRequest request) {
-    String scheme = null;
-    String host = null;
-    int port = 0;
+    String scheme;
+    String host;
+    int port;
     if (!beingProxied(request)) {
       scheme = request.getScheme();
       host = request.getServerName();

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/AbstractJWTFilterTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/AbstractJWTFilterTest.java b/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/AbstractJWTFilterTest.java
index 387b274..9712ca8 100644
--- a/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/AbstractJWTFilterTest.java
+++ b/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/AbstractJWTFilterTest.java
@@ -580,7 +580,7 @@ public abstract class AbstractJWTFilterTest  {
       handler.doFilter(request, response, chain);
       Assert.assertTrue("doFilterCalled should not be false.", chain.doFilterCalled);
       Set<PrimaryPrincipal> principals = chain.subject.getPrincipals(PrimaryPrincipal.class);
-      Assert.assertTrue("No PrimaryPrincipal", principals.size() > 0);
+      Assert.assertTrue("No PrimaryPrincipal", !principals.isEmpty());
       Assert.assertEquals("Not the expected principal", "alice", ((Principal)principals.toArray()[0]).getName());
     } catch (ServletException se) {
       fail("Should NOT have thrown a ServletException.");
@@ -726,7 +726,7 @@ public abstract class AbstractJWTFilterTest  {
   }
 
   protected static class TestFilterConfig implements FilterConfig {
-    Properties props = null;
+    Properties props;
 
     public TestFilterConfig(Properties props) {
       this.props = props;

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/JWTFederationFilterTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/JWTFederationFilterTest.java b/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/JWTFederationFilterTest.java
index f72ca6c..28d7129 100644
--- a/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/JWTFederationFilterTest.java
+++ b/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/JWTFederationFilterTest.java
@@ -64,6 +64,6 @@ public class JWTFederationFilterTest extends AbstractJWTFilterTest {
     @Override
     protected String getVerificationPemProperty() {
       return TestJWTFederationFilter.TOKEN_VERIFICATION_PEM;
-    };
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/SSOCookieProviderTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/SSOCookieProviderTest.java b/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/SSOCookieProviderTest.java
index db95a8d..e0da4f1 100644
--- a/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/SSOCookieProviderTest.java
+++ b/gateway-provider-security-jwt/src/test/java/org/apache/knox/gateway/provider/federation/SSOCookieProviderTest.java
@@ -214,7 +214,7 @@ public class SSOCookieProviderTest extends AbstractJWTFilterTest {
   @Override
   protected String getVerificationPemProperty() {
     return SSOCookieFederationFilter.SSO_VERIFICATION_PEM;
-  };
+  }
 
   private static class TestSSOCookieFederationProvider extends SSOCookieFederationFilter {
     public String testConstructLoginURL(HttpServletRequest req) {
@@ -224,6 +224,6 @@ public class SSOCookieProviderTest extends AbstractJWTFilterTest {
     public void setTokenService(JWTokenAuthority ts) {
       authority = ts;
     }
-  };
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-pac4j/src/main/java/org/apache/knox/gateway/pac4j/filter/Pac4jDispatcherFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-pac4j/src/main/java/org/apache/knox/gateway/pac4j/filter/Pac4jDispatcherFilter.java b/gateway-provider-security-pac4j/src/main/java/org/apache/knox/gateway/pac4j/filter/Pac4jDispatcherFilter.java
index 516dc5d..78c2449 100644
--- a/gateway-provider-security-pac4j/src/main/java/org/apache/knox/gateway/pac4j/filter/Pac4jDispatcherFilter.java
+++ b/gateway-provider-security-pac4j/src/main/java/org/apache/knox/gateway/pac4j/filter/Pac4jDispatcherFilter.java
@@ -152,7 +152,7 @@ public class Pac4jDispatcherFilter implements Filter {
       final PropertiesConfigFactory propertiesConfigFactory = new PropertiesConfigFactory(pac4jCallbackUrl, properties);
       config = propertiesConfigFactory.build();
       final List<Client> clients = config.getClients().getClients();
-      if (clients == null || clients.size() == 0) {
+      if (clients == null || clients.isEmpty()) {
         log.atLeastOnePac4jClientMustBeDefined();
         throw new ServletException("At least one pac4j client must be defined.");
       }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-pac4j/src/main/java/org/apache/knox/gateway/pac4j/session/KnoxSessionStore.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-pac4j/src/main/java/org/apache/knox/gateway/pac4j/session/KnoxSessionStore.java b/gateway-provider-security-pac4j/src/main/java/org/apache/knox/gateway/pac4j/session/KnoxSessionStore.java
index c1f4cb0..bce82ac 100644
--- a/gateway-provider-security-pac4j/src/main/java/org/apache/knox/gateway/pac4j/session/KnoxSessionStore.java
+++ b/gateway-provider-security-pac4j/src/main/java/org/apache/knox/gateway/pac4j/session/KnoxSessionStore.java
@@ -74,7 +74,7 @@ public class KnoxSessionStore implements SessionStore {
     }
 
     private Serializable uncompressDecryptBase64(final String v) {
-        if (v != null && v.length() > 0) {
+        if (v != null && !v.isEmpty()) {
             byte[] bytes = Base64.decodeBase64(v);
             EncryptionResult result = EncryptionResult.fromByteArray(bytes);
             byte[] clear = cryptoService.decryptForCluster(this.clusterName,

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-preauth/src/main/java/org/apache/knox/gateway/preauth/filter/HeaderPreAuthFederationFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-preauth/src/main/java/org/apache/knox/gateway/preauth/filter/HeaderPreAuthFederationFilter.java b/gateway-provider-security-preauth/src/main/java/org/apache/knox/gateway/preauth/filter/HeaderPreAuthFederationFilter.java
index 15bc657..2cd6235 100644
--- a/gateway-provider-security-preauth/src/main/java/org/apache/knox/gateway/preauth/filter/HeaderPreAuthFederationFilter.java
+++ b/gateway-provider-security-preauth/src/main/java/org/apache/knox/gateway/preauth/filter/HeaderPreAuthFederationFilter.java
@@ -56,8 +56,8 @@ public class HeaderPreAuthFederationFilter extends AbstractPreAuthFederationFilt
       String headers = request.getHeader(groupHeaderName);
       if (headers != null) {
         String[] groups = headers.split(",");
-        for (int i = 0; i < groups.length; i++) {
-          principals.add(new GroupPrincipal(groups[i]));
+        for (String group : groups) {
+          principals.add(new GroupPrincipal(group));
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/deploy/impl/ShiroConfig.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/deploy/impl/ShiroConfig.java b/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/deploy/impl/ShiroConfig.java
index 638b89b..f282d06 100644
--- a/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/deploy/impl/ShiroConfig.java
+++ b/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/deploy/impl/ShiroConfig.java
@@ -29,9 +29,9 @@ public class ShiroConfig {
 
   public ShiroConfig(Provider provider, String clusterName) {
     Map<String, String> params = provider.getParams();
-    String name = null;
-    String sectionName = null;
-    String value = null;
+    String name;
+    String sectionName;
+    String value;
     for(Entry<String, String> entry : params.entrySet()) {
       int sectionDot = entry.getKey().indexOf('.');
       if (sectionDot > 0) {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/deploy/impl/ShiroDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/deploy/impl/ShiroDeploymentContributor.java b/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/deploy/impl/ShiroDeploymentContributor.java
index 84c81d5..b379d36 100644
--- a/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/deploy/impl/ShiroDeploymentContributor.java
+++ b/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/deploy/impl/ShiroDeploymentContributor.java
@@ -73,7 +73,7 @@ public class ShiroDeploymentContributor extends ProviderDeploymentContributorBas
     SessionConfigType<WebAppDescriptor> sessionConfig = context.getWebAppDescriptor().createSessionConfig();
     Map<String, String> params = provider.getParams();
     String sts = params.get( SESSION_TIMEOUT );
-    if( sts != null && sts.trim().length() != 0 ) {
+    if( sts != null && !sts.trim().isEmpty()) {
       st = Integer.parseInt( sts.trim() );
     }
     if( st <= 0 ) {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/filter/ShiroSubjectIdentityAdapter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/filter/ShiroSubjectIdentityAdapter.java b/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/filter/ShiroSubjectIdentityAdapter.java
index 6da6170..a98ace9 100644
--- a/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/filter/ShiroSubjectIdentityAdapter.java
+++ b/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/filter/ShiroSubjectIdentityAdapter.java
@@ -72,9 +72,9 @@ public class ShiroSubjectIdentityAdapter implements Filter {
   }
 
   private static class CallableChain implements Callable<Void> {
-    private FilterChain chain = null;
-    ServletRequest request = null;
-    ServletResponse response = null;
+    private FilterChain chain;
+    ServletRequest request;
+    ServletResponse response;
 
     CallableChain(ServletRequest request, ServletResponse response, FilterChain chain) {
       this.request = request;
@@ -106,7 +106,7 @@ public class ShiroSubjectIdentityAdapter implements Filter {
       String sourceUri = (String)request.getAttribute( AbstractGatewayFilter.SOURCE_REQUEST_CONTEXT_URL_ATTRIBUTE_NAME );
       auditor.audit( Action.AUTHENTICATION , sourceUri, ResourceType.URI, ActionOutcome.SUCCESS );
 
-      Set<String> userGroups = null;
+      Set<String> userGroups;
       // map ldap groups saved in session to Java Subject GroupPrincipal(s)
       if (SecurityUtils.getSubject().getSession().getAttribute(SUBJECT_USER_GROUPS) != null) {
         userGroups = (Set<String>)SecurityUtils.getSubject().getSession().getAttribute(SUBJECT_USER_GROUPS);

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/shirorealm/KnoxLdapContextFactory.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/shirorealm/KnoxLdapContextFactory.java b/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/shirorealm/KnoxLdapContextFactory.java
index 09f10ba..7ebf554 100644
--- a/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/shirorealm/KnoxLdapContextFactory.java
+++ b/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/shirorealm/KnoxLdapContextFactory.java
@@ -75,7 +75,7 @@ public class KnoxLdapContextFactory extends JndiLdapContextFactory {
       }
 
       systemPass = systemPass.trim();
-      if (systemPass.length() == 0) {
+      if (systemPass.isEmpty()) {
         return;
       }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/shirorealm/KnoxLdapRealm.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/shirorealm/KnoxLdapRealm.java b/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/shirorealm/KnoxLdapRealm.java
index e1d1c34..1a33d57 100644
--- a/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/shirorealm/KnoxLdapRealm.java
+++ b/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/shirorealm/KnoxLdapRealm.java
@@ -572,7 +572,7 @@ public class KnoxLdapRealm extends JndiLdapRealm {
     }
     // search for the filter, substituting base with userDn
     // search for base_dn=userDn, scope=base, filter=filter
-    LdapContext systemLdapCtx = null;
+    LdapContext systemLdapCtx;
     systemLdapCtx = ldapContextFactory.getSystemLdapContext();
     NamingEnumeration<SearchResult> searchResultEnum = null;
     try {
@@ -607,8 +607,7 @@ public class KnoxLdapRealm extends JndiLdapRealm {
       principalRegex = DEFAULT_PRINCIPAL_REGEX;
     } else {
       regex = regex.trim();
-      Pattern pattern = Pattern.compile( regex );
-      principalPattern = pattern;
+      principalPattern = Pattern.compile( regex );
       principalRegex = regex;
     }
   }
@@ -694,7 +693,7 @@ public class KnoxLdapRealm extends JndiLdapRealm {
 
       // Create the searchBase and searchFilter from config.
       String searchBase = expandTemplate( getUserSearchBase(), matchedPrincipal );
-      String searchFilter = null;
+      String searchFilter;
       if ( userSearchFilter == null ) {
         if ( userSearchAttributeName == null ) {
           searchFilter = String.format( Locale.ROOT, "(objectclass=%1$s)", getUserObjectClass() );

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-webappsec/src/main/java/org/apache/knox/gateway/webappsec/filter/StrictTransportFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-webappsec/src/main/java/org/apache/knox/gateway/webappsec/filter/StrictTransportFilter.java b/gateway-provider-security-webappsec/src/main/java/org/apache/knox/gateway/webappsec/filter/StrictTransportFilter.java
index 7d2c2e7..12b2bc1 100644
--- a/gateway-provider-security-webappsec/src/main/java/org/apache/knox/gateway/webappsec/filter/StrictTransportFilter.java
+++ b/gateway-provider-security-webappsec/src/main/java/org/apache/knox/gateway/webappsec/filter/StrictTransportFilter.java
@@ -84,7 +84,7 @@ public class StrictTransportFilter implements Filter {
 
     @Override
     public String getHeader(String name) {
-        String headerValue = null;
+        String headerValue;
         if (name.equals(STRICT_TRANSPORT)) {
             headerValue = option;
         }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-webappsec/src/main/java/org/apache/knox/gateway/webappsec/filter/XContentTypeOptionsFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-webappsec/src/main/java/org/apache/knox/gateway/webappsec/filter/XContentTypeOptionsFilter.java b/gateway-provider-security-webappsec/src/main/java/org/apache/knox/gateway/webappsec/filter/XContentTypeOptionsFilter.java
index 6cec81e..4b70cd6 100644
--- a/gateway-provider-security-webappsec/src/main/java/org/apache/knox/gateway/webappsec/filter/XContentTypeOptionsFilter.java
+++ b/gateway-provider-security-webappsec/src/main/java/org/apache/knox/gateway/webappsec/filter/XContentTypeOptionsFilter.java
@@ -85,7 +85,7 @@ public class XContentTypeOptionsFilter implements Filter {
 
     @Override
     public String getHeader(String name) {
-      String headerValue = null;
+      String headerValue;
       if (name.equals(X_CONTENT_TYPE_OPTIONS_HEADER)) {
         headerValue = option;
       }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-webappsec/src/main/java/org/apache/knox/gateway/webappsec/filter/XFrameOptionsFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-webappsec/src/main/java/org/apache/knox/gateway/webappsec/filter/XFrameOptionsFilter.java b/gateway-provider-security-webappsec/src/main/java/org/apache/knox/gateway/webappsec/filter/XFrameOptionsFilter.java
index 467bd9a..977664f 100644
--- a/gateway-provider-security-webappsec/src/main/java/org/apache/knox/gateway/webappsec/filter/XFrameOptionsFilter.java
+++ b/gateway-provider-security-webappsec/src/main/java/org/apache/knox/gateway/webappsec/filter/XFrameOptionsFilter.java
@@ -84,7 +84,7 @@ public class XFrameOptionsFilter implements Filter {
 
     @Override
     public String getHeader(String name) {
-        String headerValue = null;
+        String headerValue;
         if (name.equals(X_FRAME_OPTIONS)) {
             headerValue = option;
         }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-webappsec/src/main/java/org/apache/knox/gateway/webappsec/filter/XSSProtectionFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-webappsec/src/main/java/org/apache/knox/gateway/webappsec/filter/XSSProtectionFilter.java b/gateway-provider-security-webappsec/src/main/java/org/apache/knox/gateway/webappsec/filter/XSSProtectionFilter.java
index 4045fab..a8746ee 100644
--- a/gateway-provider-security-webappsec/src/main/java/org/apache/knox/gateway/webappsec/filter/XSSProtectionFilter.java
+++ b/gateway-provider-security-webappsec/src/main/java/org/apache/knox/gateway/webappsec/filter/XSSProtectionFilter.java
@@ -82,7 +82,7 @@ public class XSSProtectionFilter implements Filter {
 
     @Override
     public String getHeader(String name) {
-      String headerValue = null;
+      String headerValue;
       if (name.equals(X_XSS_PROTECTION)) {
         headerValue = option;
       }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/StrictTransportFilterTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/StrictTransportFilterTest.java b/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/StrictTransportFilterTest.java
index 86000d3..a4a5730 100644
--- a/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/StrictTransportFilterTest.java
+++ b/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/StrictTransportFilterTest.java
@@ -101,7 +101,7 @@ public class StrictTransportFilterTest {
   }
 
   class TestFilterConfig implements FilterConfig {
-    Properties props = null;
+    Properties props;
 
     TestFilterConfig(Properties props) {
       this.props = props;

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/XFrameOptionsFilterTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/XFrameOptionsFilterTest.java b/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/XFrameOptionsFilterTest.java
index d233a09..eb085d6 100644
--- a/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/XFrameOptionsFilterTest.java
+++ b/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/XFrameOptionsFilterTest.java
@@ -130,7 +130,7 @@ public class XFrameOptionsFilterTest {
 //  }
 
   class TestFilterConfig implements FilterConfig {
-    Properties props = null;
+    Properties props;
 
     TestFilterConfig(Properties props) {
       this.props = props;

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/XSSProtectionFilterTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/XSSProtectionFilterTest.java b/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/XSSProtectionFilterTest.java
index 6fe1bb9..8d0dbca 100644
--- a/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/XSSProtectionFilterTest.java
+++ b/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/XSSProtectionFilterTest.java
@@ -93,7 +93,7 @@ public class XSSProtectionFilterTest {
   }
 
   private static class TestFilterConfig implements FilterConfig {
-    Properties props = null;
+    Properties props;
 
     TestFilterConfig(Properties props) {
       this.props = props;

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-server-xforwarded-filter/src/main/java/org/apache/knox/gateway/filter/CompositeEnumeration.java
----------------------------------------------------------------------
diff --git a/gateway-server-xforwarded-filter/src/main/java/org/apache/knox/gateway/filter/CompositeEnumeration.java b/gateway-server-xforwarded-filter/src/main/java/org/apache/knox/gateway/filter/CompositeEnumeration.java
index 93db80a..3c60e0b 100644
--- a/gateway-server-xforwarded-filter/src/main/java/org/apache/knox/gateway/filter/CompositeEnumeration.java
+++ b/gateway-server-xforwarded-filter/src/main/java/org/apache/knox/gateway/filter/CompositeEnumeration.java
@@ -25,6 +25,7 @@ public class CompositeEnumeration<T> implements Enumeration<T> {
   private int index = 0;
   private Enumeration<T>[] array;
 
+  @SafeVarargs
   public CompositeEnumeration(Enumeration<T>... enumerations) {
     if( enumerations == null ) {
       throw new IllegalArgumentException( "enumerations==null" );

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-server-xforwarded-filter/src/main/java/org/apache/knox/gateway/filter/XForwardedHeaderRequestWrapper.java
----------------------------------------------------------------------
diff --git a/gateway-server-xforwarded-filter/src/main/java/org/apache/knox/gateway/filter/XForwardedHeaderRequestWrapper.java b/gateway-server-xforwarded-filter/src/main/java/org/apache/knox/gateway/filter/XForwardedHeaderRequestWrapper.java
index c0ed341..0ed303d 100644
--- a/gateway-server-xforwarded-filter/src/main/java/org/apache/knox/gateway/filter/XForwardedHeaderRequestWrapper.java
+++ b/gateway-server-xforwarded-filter/src/main/java/org/apache/knox/gateway/filter/XForwardedHeaderRequestWrapper.java
@@ -19,7 +19,6 @@ package org.apache.knox.gateway.filter;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.Hashtable;
@@ -73,7 +72,7 @@ public class XForwardedHeaderRequestWrapper extends GatewayRequestWrapper {
     Enumeration<String> values;
     String value = proxyHeaders.get( name );
     if( value != null ) {
-      values = Collections.enumeration(Arrays.asList(value));
+      values = Collections.enumeration(Collections.singletonList(value));
     } else {
       values = super.getHeaders( name );
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-server/src/main/java/org/apache/knox/gateway/GatewayCommandLine.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/GatewayCommandLine.java b/gateway-server/src/main/java/org/apache/knox/gateway/GatewayCommandLine.java
index 3dbe6a2..e52bab5 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/GatewayCommandLine.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/GatewayCommandLine.java
@@ -37,8 +37,7 @@ public class GatewayCommandLine {
 
   public static CommandLine parse( String[] args ) throws ParseException {
     CommandLineParser parser = new PosixParser();
-    CommandLine commandLine = parser.parse( createCommandLine(), args );
-    return commandLine;
+    return parser.parse( createCommandLine(), args );
   }
 
   public static void printUsage() {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-server/src/main/java/org/apache/knox/gateway/GatewayFilter.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/GatewayFilter.java b/gateway-server/src/main/java/org/apache/knox/gateway/GatewayFilter.java
index b95ade1..e93daee 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/GatewayFilter.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/GatewayFilter.java
@@ -141,9 +141,8 @@ public class GatewayFilter implements Filter {
               int index = origUrl.indexOf(path);
               url = origUrl.substring(0, index) + "/" + defaultServicePath + path;
             }
-            String contextPath = defaultServicePath;
             servletRequest = new ForwardedRequest((HttpServletRequest) servletRequest,
-                contextPath,
+                defaultServicePath,
                 url);
           } catch (URISyntaxException e) {
             throw new ServletException( e );

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/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 ad15c65..0a90220 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
@@ -505,9 +505,9 @@ public class GatewayServer {
     } else {
       /* check for port conflict */
       final Connector[] connectors = jetty.getConnectors();
-      for (int i = 0; i < connectors.length; i++) {
-        if (connectors[i] instanceof ServerConnector
-            && ((ServerConnector) connectors[i]).getPort() == port) {
+      for (Connector connector : connectors) {
+        if (connector instanceof ServerConnector
+                && ((ServerConnector) connector).getPort() == port) {
           log.portAlreadyInUse(port, topologyName);
           throw new IOException(String.format(Locale.ROOT,
               " Port %d used by topology %s is used by other topology, ports for topologies (if defined) have to be unique. ",
@@ -950,8 +950,7 @@ public class GatewayServer {
   }
 
   private File calculateDeploymentDir( Topology topology ) {
-    File dir = new File( calculateAbsoluteDeploymentsDir(), calculateDeploymentName( topology ) );
-    return dir;
+    return new File( calculateAbsoluteDeploymentsDir(), calculateDeploymentName( topology ) );
   }
 
   private String calculateDeploymentExtension( Topology topology ) {
@@ -959,8 +958,7 @@ public class GatewayServer {
   }
 
   private String calculateDeploymentName( Topology topology ) {
-    String name = topology.getName() + calculateDeploymentExtension( topology ) + Long.toHexString( topology.getTimestamp() );
-    return name;
+    return topology.getName() + calculateDeploymentExtension( topology ) + Long.toHexString( topology.getTimestamp() );
   }
 
   private static void checkAddressAvailability( InetSocketAddress address ) throws IOException {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-server/src/main/java/org/apache/knox/gateway/GatewayServlet.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/GatewayServlet.java b/gateway-server/src/main/java/org/apache/knox/gateway/GatewayServlet.java
index ef2a27d..1f63f90 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/GatewayServlet.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/GatewayServlet.java
@@ -80,13 +80,12 @@ public class GatewayServlet implements Servlet, Filter {
   }
 
   public synchronized void setFilter( GatewayFilter filter ) throws ServletException {
-    Filter prev = filter;
     if( filterConfig != null ) {
       filter.init( filterConfig );
     }
     this.filter = filter;
-    if( prev != null && filterConfig != null ) {
-      prev.destroy();
+    if( filter != null && filterConfig != null ) {
+      ((Filter) filter).destroy();
     }
   }
 
@@ -100,10 +99,7 @@ public class GatewayServlet implements Servlet, Filter {
       if( filter != null ) {
         filter.init( filterConfig );
       }
-    } catch( ServletException e ) {
-      LOG.failedToInitializeServletInstace( e );
-      throw e;
-    } catch( RuntimeException e ) {
+    } catch( ServletException | RuntimeException e ) {
       LOG.failedToInitializeServletInstace( e );
       throw e;
     }
@@ -118,10 +114,7 @@ public class GatewayServlet implements Servlet, Filter {
       if( filter != null ) {
         filter.init( filterConfig );
       }
-    } catch( ServletException e ) {
-      LOG.failedToInitializeServletInstace( e );
-      throw e;
-    } catch( RuntimeException e ) {
+    } catch( ServletException | RuntimeException e ) {
       LOG.failedToInitializeServletInstace( e );
       throw e;
     }
@@ -140,13 +133,7 @@ public class GatewayServlet implements Servlet, Filter {
       if( f != null ) {
         try {
           f.doFilter( servletRequest, servletResponse, null );
-        } catch( IOException e ) {
-          LOG.failedToExecuteFilter( e );
-          throw e;
-        } catch( ServletException e ) {
-          LOG.failedToExecuteFilter( e );
-          throw e;
-        } catch( RuntimeException e ) {
+        } catch( IOException | RuntimeException | ServletException e ) {
           LOG.failedToExecuteFilter( e );
           throw e;
         }
@@ -176,13 +163,7 @@ public class GatewayServlet implements Servlet, Filter {
             chain.doFilter( servletRequest, servletResponse );
           }
 
-        } catch( IOException e ) {
-          LOG.failedToExecuteFilter( e );
-          throw e;
-        } catch( ServletException e ) {
-          LOG.failedToExecuteFilter( e );
-          throw e;
-        } catch( RuntimeException e ) {
+        } catch( IOException | RuntimeException | ServletException e ) {
           LOG.failedToExecuteFilter( e );
           throw e;
         }
@@ -233,9 +214,7 @@ public class GatewayServlet implements Servlet, Filter {
         }
       }
       return filter;
-    } catch( IOException e ) {
-      throw new ServletException( e );
-    } catch( URISyntaxException e ) {
+    } catch( IOException | URISyntaxException e ) {
       throw new ServletException( e );
     }
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java b/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
index 51533b7..8a613fe 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
@@ -266,7 +266,7 @@ public class GatewayConfigImpl extends Configuration implements GatewayConfig {
   public String getGatewayDataDir() {
     String systemValue =
         System.getProperty(GATEWAY_DATA_HOME_VAR, System.getenv(GATEWAY_DATA_HOME_VAR));
-    String dataDir = null;
+    String dataDir;
     if (systemValue != null) {
       dataDir = systemValue;
     } else {
@@ -928,15 +928,13 @@ public class GatewayConfigImpl extends Configuration implements GatewayConfig {
 
   @Override
   public List<String> getAutoDeployTopologyNames() {
-    List<String> topologyNames = new ArrayList<>();
 
     String value = get(AUTO_DEPLOY_TOPOLOGIES);
     if (value == null) {
       value = DEFAULT_AUTO_DEPLOY_TOPOLOGIES;
     }
-    topologyNames.addAll(Arrays.asList(value.trim().split("\\s*,\\s*")));
 
-    return topologyNames;
+    return new ArrayList<>(Arrays.asList(value.trim().split("\\s*,\\s*")));
   }
 
   @Override


Mime
View raw message