knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kris...@apache.org
Subject [2/5] knox git commit: KNOX-1664 - Miscellaneous code cleanup
Date Sat, 08 Dec 2018 14:29:55 GMT
http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-service-test/src/main/java/org/apache/knox/gateway/service/test/ServiceTestResource.java
----------------------------------------------------------------------
diff --git a/gateway-service-test/src/main/java/org/apache/knox/gateway/service/test/ServiceTestResource.java b/gateway-service-test/src/main/java/org/apache/knox/gateway/service/test/ServiceTestResource.java
index 9e8554e..b169e95 100644
--- a/gateway-service-test/src/main/java/org/apache/knox/gateway/service/test/ServiceTestResource.java
+++ b/gateway-service-test/src/main/java/org/apache/knox/gateway/service/test/ServiceTestResource.java
@@ -167,8 +167,7 @@ public class ServiceTestResource {
     GatewayConfig config = (GatewayConfig) request.getServletContext().getAttribute(GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE);
     String path = config.getGatewayPath();
 
-    String topologyName = ctxPath.replace(path, "").replace("/", "");
-    return topologyName;
+    return ctxPath.replace(path, "").replace("/", "");
   }
 
   public Topology getTopology(@PathParam("id") String id) {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-shell/src/main/java/org/apache/knox/gateway/shell/AbstractJavaConsoleCredentialCollector.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/AbstractJavaConsoleCredentialCollector.java b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/AbstractJavaConsoleCredentialCollector.java
index f234a4a..468b422 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/AbstractJavaConsoleCredentialCollector.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/AbstractJavaConsoleCredentialCollector.java
@@ -32,14 +32,13 @@ public abstract class AbstractJavaConsoleCredentialCollector extends AbstractCre
       System.exit(1);
     }
 
-    String username = c.readLine(prompt);
-    value = username;
+    value = c.readLine(prompt);
 
     return value;
   }
 
   protected String collectHiddenCredential(String prompt) {
-    char[] response = null;
+    char[] response;
     Console c = System.console();
     if (c == null) {
       System.err.println("No console.");

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSession.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSession.java b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSession.java
index b62055e..f475a42 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSession.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSession.java
@@ -302,7 +302,7 @@ public class KnoxSession implements Closeable {
   }
 
   private KeyStore getTrustStore(ClientContext clientContext) throws GeneralSecurityException {
-    KeyStore ks = null;
+    KeyStore ks;
     String truststorePass = null;
 
     discoverTruststoreDetails(clientContext);
@@ -356,8 +356,8 @@ public class KnoxSession implements Closeable {
   }
 
   protected void discoverTruststoreDetails(ClientContext clientContext) {
-    String truststoreDir = null;
-    String truststoreFileName = null;
+    String truststoreDir;
+    String truststoreFileName;
     if (clientContext.connection().truststoreLocation() != null &&
         clientContext.connection().truststorePass() != null) {
       return;
@@ -393,7 +393,7 @@ public class KnoxSession implements Closeable {
         lc.login();
         return Subject.doAs(lc.getSubject(),
             (PrivilegedAction<CloseableHttpResponse>) () -> {
-              CloseableHttpResponse response = null;
+              CloseableHttpResponse response;
               try {
                 response = client.execute(host, request, context);
                 if (response.getStatusLine().getStatusCode() < 400) {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSh.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSh.java b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSh.java
index af7b648..fa8b727 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSh.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSh.java
@@ -60,7 +60,7 @@ public class KnoxSh {
   private String gateway = null;
 
   public int run(String[] args) throws Exception {
-    int exitCode = 0;
+    int exitCode;
     try {
       exitCode = init(args);
       if (exitCode != 0) {
@@ -171,7 +171,7 @@ public class KnoxSh {
       String pass = credentials.get("pass").string();
 
       KnoxSession session = null;
-      Get.Response response = null;
+      Get.Response response;
       try {
         session = KnoxSession.login(gateway, username, pass);
 
@@ -273,23 +273,16 @@ public class KnoxSh {
   }
 
   private String readFile(String file) throws IOException {
-    BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8));
-    String line = null;
-    String content = null;
-    StringBuilder  stringBuilder = new StringBuilder();
-    String ls = System.getProperty("line.separator");
-
-    try {
-        while((line = reader.readLine()) != null) {
-            stringBuilder.append(line);
-            stringBuilder.append(ls);
-        }
-
-        content = stringBuilder.toString();
-    } finally {
-        reader.close();
+    try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
+      String line;
+      StringBuilder stringBuilder = new StringBuilder();
+      String ls = System.getProperty("line.separator");
+      while ((line = reader.readLine()) != null) {
+        stringBuilder.append(line);
+        stringBuilder.append(ls);
+      }
+      return stringBuilder.toString();
     }
-    return content;
 }
 
   /**

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hbase/HBase.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hbase/HBase.java b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hbase/HBase.java
index c1fd8dc..eda7d8d 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hbase/HBase.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hbase/HBase.java
@@ -30,8 +30,7 @@ public class HBase {
   }
 
   public static HBase session( KnoxSession session ) {
-    HBase hbase = new HBase( session );
-    return hbase;
+    return new HBase( session );
   }
 
   public SystemVersion.Request systemVersion() {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/DeployResourceRequest.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/DeployResourceRequest.java b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/DeployResourceRequest.java
index 01f03e5..a052318 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/DeployResourceRequest.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/DeployResourceRequest.java
@@ -33,9 +33,9 @@ import java.util.concurrent.Callable;
 
 class DeployResourceRequest extends AbstractRequest<BasicResponse> {
 
-  private ResourceType resourceType     = null;
-  private String       resourceName     = null;
-  private String       resourceFileName = null;
+  private ResourceType resourceType;
+  private String       resourceName;
+  private String       resourceFileName;
 
 
   DeployResourceRequest(KnoxSession session, ResourceType type, String name, String resourceFileName) {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/ListResourcesRequest.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/ListResourcesRequest.java b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/ListResourcesRequest.java
index 11bfa12..ba88a45 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/ListResourcesRequest.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/ListResourcesRequest.java
@@ -31,7 +31,7 @@ import java.util.concurrent.Callable;
 
 class ListResourcesRequest extends AbstractRequest<BasicResponse> {
 
-  private ResourceType resourceType = null;
+  private ResourceType resourceType;
 
   ListResourcesRequest(KnoxSession session, ResourceType resourceType) {
     super(session);
@@ -58,8 +58,8 @@ class ListResourcesRequest extends AbstractRequest<BasicResponse> {
     if (json != null) {
       JSONArray items = (JSONArray) json.get("items");
       if (items != null) {
-        for (int i = 0; i < items.size(); i++) {
-          JSONObject item = (JSONObject) items.get(i);
+        for (Object item1 : items) {
+          JSONObject item = (JSONObject) item1;
           String name = (String) item.get("name");
           if (name != null) {
             result.add(name.substring(0, name.lastIndexOf('.')));

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/ListTopologiesRequest.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/ListTopologiesRequest.java b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/ListTopologiesRequest.java
index 2bb3d67..b2f90a6 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/ListTopologiesRequest.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/ListTopologiesRequest.java
@@ -40,8 +40,8 @@ class ListTopologiesRequest extends ListResourcesRequest {
       if (topologies != null) {
         JSONArray items = (JSONArray) topologies.get("topology");
         if (items != null) {
-          for (int i = 0; i < items.size(); i++) {
-            JSONObject item = (JSONObject) items.get(i);
+          for (Object item1 : items) {
+            JSONObject item = (JSONObject) item1;
             String name = (String) item.get("name");
             if (name != null) {
               result.add(name);

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/ResourceType.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/ResourceType.java b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/ResourceType.java
index 4d47171..4ce7e4b 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/ResourceType.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/ResourceType.java
@@ -22,7 +22,7 @@ public class ResourceType {
   public static final ResourceType Descriptor = new ResourceType("descriptors");
   public static final ResourceType Topology = new ResourceType("topologies");
 
-  private String name = null;
+  private String name;
 
   private ResourceType(String type) {
     this.name = type;

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/UndeployResourceRequest.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/UndeployResourceRequest.java b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/UndeployResourceRequest.java
index c6a21b4..0bb9973 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/UndeployResourceRequest.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/manager/UndeployResourceRequest.java
@@ -26,8 +26,8 @@ import java.util.concurrent.Callable;
 
 class UndeployResourceRequest extends AbstractRequest<BasicResponse> {
 
-  private ResourceType resourceType = null;
-  private String resourceName = null;
+  private ResourceType resourceType;
+  private String resourceName;
 
 
   UndeployResourceRequest(KnoxSession session, ResourceType type, String name) {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/AbstractGatewayDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/AbstractGatewayDispatch.java b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/AbstractGatewayDispatch.java
index cf60458..d566995 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/AbstractGatewayDispatch.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/AbstractGatewayDispatch.java
@@ -86,8 +86,7 @@ public abstract class AbstractGatewayDispatch implements Dispatch {
       str.append('?');
       str.append(query);
     }
-    URI url = URI.create(str.toString());
-    return url;
+    return URI.create(str.toString());
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/CappedBufferHttpEntity.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/CappedBufferHttpEntity.java b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/CappedBufferHttpEntity.java
index 8e5d455..6ce6bea 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/CappedBufferHttpEntity.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/CappedBufferHttpEntity.java
@@ -123,7 +123,7 @@ public class CappedBufferHttpEntity extends HttpEntityWrapper {
 
     @Override
     public int read(byte[] buffer, int offset, int limit ) throws IOException {
-      int count = -1;
+      int count;
       // If we can read from the buffer do so.
       if( replayReadIndex < replayWriteIndex ) {
         count = replayWriteIndex - replayReadIndex;

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/DefaultHttpClientFactory.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/DefaultHttpClientFactory.java b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/DefaultHttpClientFactory.java
index fd69e74..a50bd49 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/DefaultHttpClientFactory.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/DefaultHttpClientFactory.java
@@ -68,7 +68,7 @@ public class DefaultHttpClientFactory implements HttpClientFactory {
 
   @Override
   public HttpClient createHttpClient(FilterConfig filterConfig) {
-    HttpClientBuilder builder = null;
+    HttpClientBuilder builder;
     GatewayConfig gatewayConfig = (GatewayConfig) filterConfig.getServletContext().getAttribute(GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE);
     GatewayServices services = (GatewayServices) filterConfig.getServletContext()
         .getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE);

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/HadoopAuthCookieStore.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/HadoopAuthCookieStore.java b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/HadoopAuthCookieStore.java
index f921b3a..64ca2f8 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/HadoopAuthCookieStore.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/HadoopAuthCookieStore.java
@@ -36,7 +36,7 @@ public class HadoopAuthCookieStore extends BasicCookieStore {
 
   private static SpiGatewayMessages LOG = MessagesFactory.get( SpiGatewayMessages.class );
 
-  private GatewayConfig gatewayConfig = null;
+  private GatewayConfig gatewayConfig;
 
 
   HadoopAuthCookieStore(GatewayConfig config) {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/InputStreamEntity.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/InputStreamEntity.java b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/InputStreamEntity.java
index e1975aa..f16c880 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/InputStreamEntity.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/InputStreamEntity.java
@@ -121,29 +121,26 @@ public class InputStreamEntity extends AbstractHttpEntity {
   @Override
   public void writeTo(final OutputStream outstream ) throws IOException {
     Args.notNull( outstream, "Output stream" );
-    final InputStream instream = this.content;
-    try {
-      final byte[] buffer = new byte[ OUTPUT_BUFFER_SIZE ];
+    try (InputStream instream = this.content) {
+      final byte[] buffer = new byte[OUTPUT_BUFFER_SIZE];
       int l;
-      if( this.length < 0 ) {
+      if (this.length < 0) {
         // consume until EOF
-        while( ( l = instream.read( buffer ) ) != -1 ) {
-          outstream.write( buffer, 0, l );
+        while ((l = instream.read(buffer)) != -1) {
+          outstream.write(buffer, 0, l);
         }
       } else {
         // consume no more than length
         long remaining = this.length;
-        while( remaining > 0 ) {
-          l = instream.read( buffer, 0, (int)Math.min( OUTPUT_BUFFER_SIZE, remaining ) );
-          if( l == -1 ) {
+        while (remaining > 0) {
+          l = instream.read(buffer, 0, (int) Math.min(OUTPUT_BUFFER_SIZE, remaining));
+          if (l == -1) {
             break;
           }
-          outstream.write( buffer, 0, l );
+          outstream.write(buffer, 0, l);
           remaining -= l;
         }
       }
-    } finally {
-      instream.close();
     }
   }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/PartiallyRepeatableHttpEntity.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/PartiallyRepeatableHttpEntity.java b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/PartiallyRepeatableHttpEntity.java
index b9c18ed..bdd32fc 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/PartiallyRepeatableHttpEntity.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/PartiallyRepeatableHttpEntity.java
@@ -131,7 +131,7 @@ public class PartiallyRepeatableHttpEntity extends HttpEntityWrapper {
 
     @Override
     public int read(byte[] buffer, int offset, int limit ) throws IOException {
-      int count = -1;
+      int count;
       if( finalStream != null && finalStream != this ) {
         throw new IOException( "Replay stream taken over by another consumer." );
       }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-spi/src/main/java/org/apache/knox/gateway/filter/AbstractGatewayFilter.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/filter/AbstractGatewayFilter.java b/gateway-spi/src/main/java/org/apache/knox/gateway/filter/AbstractGatewayFilter.java
index 9377d95..59770c4 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/filter/AbstractGatewayFilter.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/filter/AbstractGatewayFilter.java
@@ -56,10 +56,7 @@ public abstract class AbstractGatewayFilter implements Filter {
       throws IOException, ServletException {
     try {
       doFilter( (HttpServletRequest)request, (HttpServletResponse)response, chain );
-    } catch( IOException e ) {
-      LOG.failedToExecuteFilter( e );
-      throw e;
-    } catch( ServletException e ) {
+    } catch( IOException | ServletException e ) {
       LOG.failedToExecuteFilter( e );
       throw e;
     } catch( Throwable t ) {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-spi/src/main/java/org/apache/knox/gateway/security/GroupPrincipal.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/security/GroupPrincipal.java b/gateway-spi/src/main/java/org/apache/knox/gateway/security/GroupPrincipal.java
index ba623ca..f0cd865 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/security/GroupPrincipal.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/security/GroupPrincipal.java
@@ -20,7 +20,7 @@ package org.apache.knox.gateway.security;
 import java.security.Principal;
 
 public class GroupPrincipal implements Principal {
-  private String name = null;
+  private String name;
 
   public GroupPrincipal(String name) {
     this.name = name;

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-spi/src/main/java/org/apache/knox/gateway/security/ImpersonatedPrincipal.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/security/ImpersonatedPrincipal.java b/gateway-spi/src/main/java/org/apache/knox/gateway/security/ImpersonatedPrincipal.java
index 1e134b3..850c732 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/security/ImpersonatedPrincipal.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/security/ImpersonatedPrincipal.java
@@ -20,7 +20,7 @@ package org.apache.knox.gateway.security;
 import java.security.Principal;
 
 public class ImpersonatedPrincipal implements Principal {
-  private String name = null;
+  private String name;
 
   public ImpersonatedPrincipal(String name) {
     this.name = name;

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-spi/src/main/java/org/apache/knox/gateway/security/PrimaryPrincipal.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/security/PrimaryPrincipal.java b/gateway-spi/src/main/java/org/apache/knox/gateway/security/PrimaryPrincipal.java
index 59ed99e..bca7bbb 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/security/PrimaryPrincipal.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/security/PrimaryPrincipal.java
@@ -20,7 +20,7 @@ package org.apache.knox.gateway.security;
 import java.security.Principal;
 
 public class PrimaryPrincipal implements Principal {
-  private String name = null;
+  private String name;
 
   public PrimaryPrincipal(String name) {
     this.name = name;

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-spi/src/main/java/org/apache/knox/gateway/security/PromptUtils.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/security/PromptUtils.java b/gateway-spi/src/main/java/org/apache/knox/gateway/security/PromptUtils.java
index 004ef56..e815622 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/security/PromptUtils.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/security/PromptUtils.java
@@ -53,7 +53,7 @@ public class PromptUtils {
   }
 
   public static UsernamePassword challengeUserNamePassword(String prompt1, String prompt2) {
-    UsernamePassword response = null;
+    UsernamePassword response;
     Console c = System.console();
     if (c == null) {
       System.err.println("No console.");
@@ -68,7 +68,7 @@ public class PromptUtils {
   }
 
   public static char[] challengeForPassword(String prompt) {
-    char[] response = null;
+    char[] response;
     Console c = System.console();
     if (c == null) {
       System.err.println("No console.");

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-spi/src/main/java/org/apache/knox/gateway/security/SubjectUtils.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/security/SubjectUtils.java b/gateway-spi/src/main/java/org/apache/knox/gateway/security/SubjectUtils.java
index aac20af..8f3e74e 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/security/SubjectUtils.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/security/SubjectUtils.java
@@ -51,7 +51,7 @@ public class SubjectUtils {
   }
 
   public static boolean isImpersonating(Subject subject) {
-    return (subject.getPrincipals(ImpersonatedPrincipal.class).size() > 0);
+    return (!subject.getPrincipals(ImpersonatedPrincipal.class).isEmpty());
   }
 
   public static String getImpersonatedPrincipalName(Subject subject) {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-spi/src/main/java/org/apache/knox/gateway/security/UsernamePassword.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/security/UsernamePassword.java b/gateway-spi/src/main/java/org/apache/knox/gateway/security/UsernamePassword.java
index 1fc9967..92013fd 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/security/UsernamePassword.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/security/UsernamePassword.java
@@ -19,7 +19,7 @@ package org.apache.knox.gateway.security;
 
 public class UsernamePassword {
   private String username;
-  private char[] password = null;
+  private char[] password;
 
   public UsernamePassword(String username, char[] password) {
     super();

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-spi/src/main/java/org/apache/knox/gateway/security/principal/SimplePrincipalMapper.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/security/principal/SimplePrincipalMapper.java b/gateway-spi/src/main/java/org/apache/knox/gateway/security/principal/SimplePrincipalMapper.java
index fc7db6c..94dcc8d 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/security/principal/SimplePrincipalMapper.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/security/principal/SimplePrincipalMapper.java
@@ -51,8 +51,8 @@ public class SimplePrincipalMapper implements PrincipalMapper {
           String value = mapping.substring(mapping.indexOf('=')+1);
           String[] v = value.split(",");
           String[] p = principals.split(",");
-          for(int i = 0; i < p.length; i++) {
-            table.put(p[i], v);
+          for (String s : p) {
+            table.put(s, v);
           }
         } while(t.hasMoreTokens());
       }
@@ -81,7 +81,7 @@ public class SimplePrincipalMapper implements PrincipalMapper {
   @Override
   public String[] mapGroupPrincipal(String principalName) {
     String[] groups = null;
-    String[] wildCardGroups = null;
+    String[] wildCardGroups;
 
     if (groupMappings != null) {
       groups = groupMappings.get(principalName);

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/BaseKeystoreService.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/BaseKeystoreService.java b/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/BaseKeystoreService.java
index 1f5ba58..ff4b851 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/BaseKeystoreService.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/BaseKeystoreService.java
@@ -26,7 +26,6 @@ import org.apache.knox.gateway.services.security.MasterService;
 import javax.crypto.spec.SecretKeySpec;
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -84,19 +83,7 @@ public class BaseKeystoreService {
       KeyStore ks = KeyStore.getInstance(keystoreType);
       ks.load( null, null );
       ks.store( out, masterService.getMasterSecret() );
-    } catch (KeyStoreException e) {
-      LOG.failedToCreateKeystore( filename, keystoreType, e );
-      throw new KeystoreServiceException(e);
-    } catch (NoSuchAlgorithmException e) {
-      LOG.failedToCreateKeystore( filename, keystoreType, e );
-      throw new KeystoreServiceException(e);
-    } catch (CertificateException e) {
-      LOG.failedToCreateKeystore( filename, keystoreType, e );
-      throw new KeystoreServiceException(e);
-    } catch (FileNotFoundException e) {
-      LOG.failedToCreateKeystore( filename, keystoreType, e );
-      throw new KeystoreServiceException(e);
-    } catch (IOException e) {
+    } catch (NoSuchAlgorithmException | CertificateException | KeyStoreException | IOException e) {
       LOG.failedToCreateKeystore( filename, keystoreType, e );
       throw new KeystoreServiceException(e);
     }
@@ -119,19 +106,10 @@ public class BaseKeystoreService {
   }
 
   protected KeyStore getKeystore(final File keyStoreFile, String storeType) throws KeystoreServiceException {
-    KeyStore credStore = null;
+    KeyStore credStore;
     try {
       credStore = loadKeyStore( keyStoreFile, masterService.getMasterSecret(), storeType);
-    } catch (CertificateException e) {
-      LOG.failedToLoadKeystore( keyStoreFile.getName(), storeType, e );
-      throw new KeystoreServiceException(e);
-    } catch (KeyStoreException e) {
-      LOG.failedToLoadKeystore( keyStoreFile.getName(), storeType, e );
-      throw new KeystoreServiceException(e);
-    } catch (NoSuchAlgorithmException e) {
-      LOG.failedToLoadKeystore( keyStoreFile.getName(), storeType, e );
-      throw new KeystoreServiceException(e);
-    } catch (IOException e) {
+    } catch (CertificateException | IOException | NoSuchAlgorithmException | KeyStoreException e) {
       LOG.failedToLoadKeystore( keyStoreFile.getName(), storeType, e );
       throw new KeystoreServiceException(e);
     }
@@ -169,11 +147,7 @@ public class BaseKeystoreService {
     if (ks != null) {
       try {
         credential = new String(ks.getKey(alias, masterService.getMasterSecret()).getEncoded(), StandardCharsets.UTF_8).toCharArray();
-      } catch (UnrecoverableKeyException e) {
-        LOG.failedToGetCredential(e);
-      } catch (KeyStoreException e) {
-        LOG.failedToGetCredential(e);
-      } catch (NoSuchAlgorithmException e) {
+      } catch (UnrecoverableKeyException | NoSuchAlgorithmException | KeyStoreException e) {
         LOG.failedToGetCredential(e);
       }
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/CMFKeystoreService.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/CMFKeystoreService.java b/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/CMFKeystoreService.java
index 0e4c9ab..4b41692 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/CMFKeystoreService.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/CMFKeystoreService.java
@@ -41,7 +41,7 @@ public class CMFKeystoreService extends BaseKeystoreService {
   private static final String TEST_CERT_DN = "CN=hadoop,OU=Test,O=Hadoop,L=Test,ST=Test,C=US";
   private static final String CREDENTIALS_SUFFIX = "-credentials.jceks";
 
-  private String serviceName = null;
+  private String serviceName;
 
   public CMFKeystoreService(String keystoreDir, String serviceName)
       throws ServiceLifecycleException {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/CMFMasterService.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/CMFMasterService.java b/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/CMFMasterService.java
index 4996030..961e7da 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/CMFMasterService.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/CMFMasterService.java
@@ -40,7 +40,7 @@ public class CMFMasterService {
   private static final String MASTER_PASSPHRASE = "masterpassphrase";
   private static final String MASTER_PERSISTENCE_TAG = "#1.0# " + TimeStamp.getCurrentTime().toDateString();
   protected char[] master = null;
-  protected String serviceName = null;
+  protected String serviceName;
   private ConfigurableEncryptor encryptor = new ConfigurableEncryptor(MASTER_PASSPHRASE);
 
   public CMFMasterService(String serviceName) {
@@ -170,14 +170,11 @@ public class CMFMasterService {
         this.master = new String(encryptor.decrypt(Base64.decodeBase64(parts[0]),
             Base64.decodeBase64(parts[1]), Base64.decodeBase64(parts[2])),
             StandardCharsets.UTF_8).toCharArray();
-      } catch (IOException e) {
-        LOG.failedToInitializeFromPersistentMaster(masterFile.getName(), e);
-        throw e;
       } catch (Exception e) {
         LOG.failedToInitializeFromPersistentMaster(masterFile.getName(), e);
         throw e;
       }
-    }
+  }
 
   private void chmod(String args, File file) throws IOException {
       // TODO: move to Java 7 NIO support to add windows as well

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/ConfigurableEncryptor.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/ConfigurableEncryptor.java b/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/ConfigurableEncryptor.java
index f3361d8..f7e8691 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/ConfigurableEncryptor.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/ConfigurableEncryptor.java
@@ -41,7 +41,7 @@ public class ConfigurableEncryptor {
   private static final int ITERATION_COUNT = 65536;
   private static final int KEY_LENGTH = 128;
 
-  private char[] passPhrase = null;
+  private char[] passPhrase;
   private String alg = "AES";
   private String pbeAlg = "PBKDF2WithHmacSHA1";
   private String transformation = "AES/CBC/PKCS5Padding";
@@ -89,9 +89,7 @@ public class ConfigurableEncryptor {
       factory = SecretKeyFactory.getInstance(pbeAlg);
       KeySpec spec = new PBEKeySpec(passPhrase.toCharArray(), salt, iterationCount, keyLength);
       key = factory.generateSecret(spec);
-    } catch (NoSuchAlgorithmException e) {
-      LOG.failedToGenerateKeyFromPassword( e );
-    } catch (InvalidKeySpecException e) {
+    } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
       LOG.failedToGenerateKeyFromPassword( e );
     }
 
@@ -112,10 +110,9 @@ public class ConfigurableEncryptor {
     SecretKey secret = new SecretKeySpec(tmp.getEncoded(), alg);
     Cipher ecipher = Cipher.getInstance(transformation);
     ecipher.init(Cipher.ENCRYPT_MODE, secret);
-    EncryptionResult atom = new EncryptionResult(salt,
+    return new EncryptionResult(salt,
         ecipher.getParameters().getParameterSpec(IvParameterSpec.class).getIV(),
         ecipher.doFinal(plain));
-    return atom;
   }
 
   public byte[] decrypt(byte[] salt, byte[] iv, byte[] encrypt) throws Exception {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/token/impl/JWTToken.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/token/impl/JWTToken.java b/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/token/impl/JWTToken.java
index da8bfe3..35d5e08 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/token/impl/JWTToken.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/token/impl/JWTToken.java
@@ -36,7 +36,7 @@ import com.nimbusds.jwt.SignedJWT;
 public class JWTToken implements JWT {
   private static JWTProviderMessages log = MessagesFactory.get( JWTProviderMessages.class );
 
-  SignedJWT jwt = null;
+  SignedJWT jwt;
 
   private JWTToken(String header, String claims, String signature) throws ParseException {
     jwt = new SignedJWT(new Base64URL(header), new Base64URL(claims), new Base64URL(signature));
@@ -64,7 +64,7 @@ public class JWTToken implements JWT {
       }
       audiences.add(claimsArray[2]);
     }
-    JWTClaimsSet claims = null;
+    JWTClaimsSet claims;
     JWTClaimsSet.Builder builder = new JWTClaimsSet.Builder()
     .issuer(claimsArray[0])
     .subject(claimsArray[1])
@@ -87,7 +87,7 @@ public class JWTToken implements JWT {
   @Override
   public String getClaims() {
     String c = null;
-    JWTClaimsSet claims = null;
+    JWTClaimsSet claims;
     try {
       claims = jwt.getJWTClaimsSet();
       c = claims.toJSONObject().toJSONString();
@@ -154,7 +154,7 @@ public class JWTToken implements JWT {
 
   @Override
   public String getAudience() {
-    String[] claim = null;
+    String[] claim;
     String c = null;
 
     claim = getAudienceClaims();

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-spi/src/main/java/org/apache/knox/gateway/topology/Version.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/topology/Version.java b/gateway-spi/src/main/java/org/apache/knox/gateway/topology/Version.java
index e2151ac..48cd147 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/topology/Version.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/topology/Version.java
@@ -107,13 +107,11 @@ public class Version implements Comparable<Version> {
 
   @Override
   public String toString() {
-    StringBuffer buffer = new StringBuffer();
-    buffer.append(major);
-    buffer.append(".");
-    buffer.append(minor);
-    buffer.append(".");
-    buffer.append(patch);
-    return buffer.toString();
+    return major +
+                        "." +
+                        minor +
+                        "." +
+                        patch;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test-release-utils/src/main/java/org/apache/knox/gateway/GatewayTestConfig.java
----------------------------------------------------------------------
diff --git a/gateway-test-release-utils/src/main/java/org/apache/knox/gateway/GatewayTestConfig.java b/gateway-test-release-utils/src/main/java/org/apache/knox/gateway/GatewayTestConfig.java
index 118f861..1fb183a 100644
--- a/gateway-test-release-utils/src/main/java/org/apache/knox/gateway/GatewayTestConfig.java
+++ b/gateway-test-release-utils/src/main/java/org/apache/knox/gateway/GatewayTestConfig.java
@@ -36,8 +36,8 @@ public class GatewayTestConfig extends Configuration implements GatewayConfig {
 
   /* Websocket defaults */
   public static final boolean DEFAULT_WEBSOCKET_FEATURE_ENABLED = false;
-  public static final int DEFAULT_WEBSOCKET_MAX_TEXT_MESSAGE_SIZE = Integer.MAX_VALUE;;
-  public static final int DEFAULT_WEBSOCKET_MAX_BINARY_MESSAGE_SIZE = Integer.MAX_VALUE;;
+  public static final int DEFAULT_WEBSOCKET_MAX_TEXT_MESSAGE_SIZE = Integer.MAX_VALUE;
+  public static final int DEFAULT_WEBSOCKET_MAX_BINARY_MESSAGE_SIZE = Integer.MAX_VALUE;
   public static final int DEFAULT_WEBSOCKET_MAX_TEXT_MESSAGE_BUFFER_SIZE = 32768;
   public static final int DEFAULT_WEBSOCKET_MAX_BINARY_MESSAGE_BUFFER_SIZE = 32768;
   public static final int DEFAULT_WEBSOCKET_INPUT_BUFFER_SIZE = 4096;

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test-release-utils/src/main/java/org/apache/knox/gateway/GatewayTestDriver.java
----------------------------------------------------------------------
diff --git a/gateway-test-release-utils/src/main/java/org/apache/knox/gateway/GatewayTestDriver.java b/gateway-test-release-utils/src/main/java/org/apache/knox/gateway/GatewayTestDriver.java
index dae6812..03bbdad 100644
--- a/gateway-test-release-utils/src/main/java/org/apache/knox/gateway/GatewayTestDriver.java
+++ b/gateway-test-release-utils/src/main/java/org/apache/knox/gateway/GatewayTestDriver.java
@@ -292,7 +292,7 @@ public class GatewayTestDriver {
   }
 
   public InputStream getResourceStream( String resource ) throws IOException {
-    InputStream stream = null;
+    InputStream stream;
     if( resource.startsWith( "file:/" ) ) {
       try {
         stream = FileUtils.openInputStream( new File( new URI( resource ) ) );

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test-release/webhdfs-kerb-test/src/test/java/org/apache/knox/gateway/SecureClusterTest.java
----------------------------------------------------------------------
diff --git a/gateway-test-release/webhdfs-kerb-test/src/test/java/org/apache/knox/gateway/SecureClusterTest.java b/gateway-test-release/webhdfs-kerb-test/src/test/java/org/apache/knox/gateway/SecureClusterTest.java
index 145377b..5909163 100644
--- a/gateway-test-release/webhdfs-kerb-test/src/test/java/org/apache/knox/gateway/SecureClusterTest.java
+++ b/gateway-test-release/webhdfs-kerb-test/src/test/java/org/apache/knox/gateway/SecureClusterTest.java
@@ -257,7 +257,7 @@ public class SecureClusterTest {
    * @return A populated XML structure for a topology file.
    */
   private static XMLTag createTopology() {
-    XMLTag xml = XMLDoc.newDocument(true)
+    return XMLDoc.newDocument(true)
         .addRoot("topology")
         .addTag("gateway")
         .addTag("provider")
@@ -302,6 +302,5 @@ public class SecureClusterTest {
         .addTag("role").addText("WEBHDFS")
         .addTag("url").addText("http://localhost:" + nameNodeHttpPort + "/webhdfs/").gotoParent()
         .gotoRoot();
-    return xml;
   }
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test-release/webhdfs-kerb-test/src/test/java/org/apache/knox/gateway/SecureKnoxShellTest.java
----------------------------------------------------------------------
diff --git a/gateway-test-release/webhdfs-kerb-test/src/test/java/org/apache/knox/gateway/SecureKnoxShellTest.java b/gateway-test-release/webhdfs-kerb-test/src/test/java/org/apache/knox/gateway/SecureKnoxShellTest.java
index 7ac7cc8..fddda57 100644
--- a/gateway-test-release/webhdfs-kerb-test/src/test/java/org/apache/knox/gateway/SecureKnoxShellTest.java
+++ b/gateway-test-release/webhdfs-kerb-test/src/test/java/org/apache/knox/gateway/SecureKnoxShellTest.java
@@ -232,7 +232,7 @@ public class SecureKnoxShellTest {
    * @return A populated XML structure for a topology file.
    */
   private static XMLTag createSecureTopology() {
-    XMLTag xml = XMLDoc.newDocument(true).addRoot("topology").addTag("gateway")
+    return XMLDoc.newDocument(true).addRoot("topology").addTag("gateway")
         .addTag("provider").addTag("role").addText("authentication")
         .addTag("name").addText("HadoopAuth").addTag("enabled").addText("true")
 
@@ -283,9 +283,6 @@ public class SecureKnoxShellTest {
         .addTag("service").addTag("role").addText("WEBHDFS").addTag("url")
         .addText("http://localhost:" + nameNodeHttpPort + "/webhdfs/")
         .gotoParent().gotoRoot();
-
-    //System.out.println( "GATEWAY=" + xml.toString() );
-    return xml;
   }
 
   private static void setupLogging() {
@@ -341,8 +338,7 @@ public class SecureKnoxShellTest {
     String filePath =
         this.getClass().getCanonicalName().replaceAll("\\.", "/") + "/"
             + resource;
-    URL url = ClassLoader.getSystemResource(filePath);
-    return url;
+    return ClassLoader.getSystemResource(filePath);
   }
 
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test-release/webhdfs-test/src/test/java/org/apache/knox/gateway/ShellTest.java
----------------------------------------------------------------------
diff --git a/gateway-test-release/webhdfs-test/src/test/java/org/apache/knox/gateway/ShellTest.java b/gateway-test-release/webhdfs-test/src/test/java/org/apache/knox/gateway/ShellTest.java
index 8b989cb..54365d8 100644
--- a/gateway-test-release/webhdfs-test/src/test/java/org/apache/knox/gateway/ShellTest.java
+++ b/gateway-test-release/webhdfs-test/src/test/java/org/apache/knox/gateway/ShellTest.java
@@ -137,7 +137,7 @@ public class ShellTest {
    * @return A populated XML structure for a topology file.
    */
   private static XMLTag createTopology() {
-    XMLTag xml = XMLDoc.newDocument(true)
+    return XMLDoc.newDocument(true)
         .addRoot("topology")
         .addTag( "gateway" )
         .addTag( "provider" )
@@ -182,8 +182,5 @@ public class ShellTest {
         .addTag("role").addText("WEBHDFS")
         .addTag("url").addText("http://localhost:" + nameNodeHttpPort + "/webhdfs/").gotoParent()
         .gotoRoot();
-//     System.out.println( "GATEWAY=" + xml.toString() );
-    return xml;
   }
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test-utils/src/main/java/org/apache/knox/test/TestUtils.java
----------------------------------------------------------------------
diff --git a/gateway-test-utils/src/main/java/org/apache/knox/test/TestUtils.java b/gateway-test-utils/src/main/java/org/apache/knox/test/TestUtils.java
index 23e9380..f17668d 100644
--- a/gateway-test-utils/src/main/java/org/apache/knox/test/TestUtils.java
+++ b/gateway-test-utils/src/main/java/org/apache/knox/test/TestUtils.java
@@ -81,14 +81,12 @@ public class TestUtils {
 
   public static InputStream getResourceStream( String name ) throws IOException {
     URL url = ClassLoader.getSystemResource( name );
-    InputStream stream = url.openStream();
-    return stream;
+    return url.openStream();
   }
 
   public static InputStream getResourceStream( Class clazz, String name ) throws IOException {
     URL url = getResourceUrl( clazz, name );
-    InputStream stream = url.openStream();
-    return stream;
+    return url.openStream();
   }
 
   public static Reader getResourceReader( String name, Charset charset ) throws IOException {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockRequestMatcher.java
----------------------------------------------------------------------
diff --git a/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockRequestMatcher.java b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockRequestMatcher.java
index 5be7739..fc1246a 100644
--- a/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockRequestMatcher.java
+++ b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockRequestMatcher.java
@@ -33,6 +33,7 @@ import java.net.URL;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -84,9 +85,7 @@ public class MockRequestMatcher {
       this.methods = new HashSet<>();
     }
     if( methods != null ) {
-      for( String method: methods ) {
-        this.methods.add( method );
-      }
+      Collections.addAll(this.methods, methods);
     }
     return this;
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminFuncTest.java
index 6fefd05..8668985 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminFuncTest.java
@@ -112,7 +112,8 @@ public class GatewayAdminFuncTest {
   }
 
   private static XMLTag createTopology() {
-    XMLTag xml = XMLDoc.newDocument( true )
+    // System.out.println( "GATEWAY=" + xml.toString() );
+    return XMLDoc.newDocument( true )
         .addRoot( "topology" )
         .addTag( "gateway" )
         .addTag( "provider" )
@@ -143,8 +144,6 @@ public class GatewayAdminFuncTest {
         .addTag( "service" )
         .addTag( "role" ).addText( "KNOX" )
         .gotoRoot();
-    // System.out.println( "GATEWAY=" + xml.toString() );
-    return xml;
   }
 
   //@Test

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminTopologyFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminTopologyFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminTopologyFuncTest.java
index 82952fd..3b67938 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminTopologyFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminTopologyFuncTest.java
@@ -157,7 +157,8 @@ public class GatewayAdminTopologyFuncTest {
   }
 
   private static XMLTag createNormalTopology() {
-    XMLTag xml = XMLDoc.newDocument( true )
+    //     System.out.println( "GATEWAY=" + xml.toString() );
+    return XMLDoc.newDocument( true )
         .addRoot( "topology" )
         .addTag( "gateway" )
         .addTag( "provider" )
@@ -202,12 +203,11 @@ public class GatewayAdminTopologyFuncTest {
         .addTag( "role" ).addText( "WEBHDFS" )
         .addTag( "url" ).addText( "http://localhost:50070/webhdfs/v1" ).gotoParent()
         .gotoRoot();
-//     System.out.println( "GATEWAY=" + xml.toString() );
-    return xml;
   }
 
   private static XMLTag createKnoxTopology() {
-    XMLTag xml = XMLDoc.newDocument( true )
+    // System.out.println( "GATEWAY=" + xml.toString() );
+    return XMLDoc.newDocument( true )
         .addRoot( "topology" )
         .addTag( "gateway" )
         .addTag( "provider" )
@@ -244,12 +244,11 @@ public class GatewayAdminTopologyFuncTest {
         .addTag( "service" )
         .addTag( "role" ).addText( "KNOX" )
         .gotoRoot();
-    // System.out.println( "GATEWAY=" + xml.toString() );
-    return xml;
   }
 
   private static XMLTag createProviderConfiguration() {
-    XMLTag xml = XMLDoc.newDocument( true )
+    // System.out.println( "GATEWAY=" + xml.toString() );
+    return XMLDoc.newDocument( true )
             .addRoot( "gateway" )
             .addTag( "provider" )
             .addTag( "role" ).addText( "authentication" )
@@ -282,8 +281,6 @@ public class GatewayAdminTopologyFuncTest {
             .addTag( "enabled" ).addText( "true" )
             .addTag( "name" ).addText( "Default" ).gotoParent()
             .gotoRoot();
-    // System.out.println( "GATEWAY=" + xml.toString() );
-    return xml;
   }
 
   private static String createDescriptor(String clusterName) {

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test/src/test/java/org/apache/knox/gateway/GatewayBasicFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayBasicFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayBasicFuncTest.java
index ade5807..ef4e760 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayBasicFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayBasicFuncTest.java
@@ -192,7 +192,8 @@ public class GatewayBasicFuncTest {
    * @return A populated XML structure for a topology file.
    */
   private static XMLTag createTopology() {
-    XMLTag xml = XMLDoc.newDocument( true )
+    //     System.out.println( "GATEWAY=" + xml.toString() );
+    return XMLDoc.newDocument( true )
         .addRoot( "topology" )
           .addTag( "gateway" )
             .addTag( "provider" )
@@ -278,8 +279,6 @@ public class GatewayBasicFuncTest {
         .addTag("service")
         .addTag("role").addText("SERVICE-TEST")
         .gotoRoot();
-//     System.out.println( "GATEWAY=" + xml.toString() );
-    return xml;
   }
 
   @Test( timeout = TestUtils.MEDIUM_TIMEOUT )
@@ -1036,7 +1035,7 @@ public class GatewayBasicFuncTest {
 
     String success = "SUCCEEDED";
     String status = "UNKNOWN";
-    long delay = 1000 * 1; // 1 second.
+    long delay = 1000; // 1 second.
     long limit = 1000 * 60; // 60 seconds.
     long start = System.currentTimeMillis();
     while( System.currentTimeMillis() <= start+limit ) {
@@ -2191,7 +2190,7 @@ public class GatewayBasicFuncTest {
     String path = "/v1/cluster/apps/";
     String resource = "/yarn/apps";
     String gatewayPath = driver.getUrl( "RESOURCEMANAGER" ) + path;
-    String gatewayPathQuery = driver.isUseGateway() ? "" : "?user.name=" + username;
+    StringBuilder gatewayPathQuery = new StringBuilder(driver.isUseGateway() ? "" : "?user.name=" + username);
     InetSocketAddress gatewayAddress = driver.gateway.getAddresses()[0];
     String gatewayHostName = gatewayAddress.getHostName();
     String gatewayAddrName = InetAddress.getByName( gatewayHostName ).getHostAddress();
@@ -2213,12 +2212,12 @@ public class GatewayBasicFuncTest {
     if ( params != null ) {
       for (Entry<String, String> param : params.entrySet()) {
         mockRequestMatcher.queryParam( param.getKey(), param.getValue() );
-        if (gatewayPathQuery.isEmpty()) {
-          gatewayPathQuery += "?";
+        if (gatewayPathQuery.length() == 0) {
+          gatewayPathQuery.append("?");
         } else {
-          gatewayPathQuery += "&";
+          gatewayPathQuery.append("&");
         }
-        gatewayPathQuery += param.getKey() + "=" + param.getValue();
+        gatewayPathQuery.append(param.getKey()).append("=").append(param.getValue());
       }
     }
 
@@ -2537,7 +2536,7 @@ public class GatewayBasicFuncTest {
     String nodeResource = "/yarn/node";
     String nodeId = "localhost:45454";
     String gatewayPath = driver.getUrl( "RESOURCEMANAGER" ) + path;
-    String gatewayPathQuery = driver.isUseGateway() ? "" : "?user.name=" + username;
+    StringBuilder gatewayPathQuery = new StringBuilder(driver.isUseGateway() ? "" : "?user.name=" + username);
 
 
     MockRequestMatcher mockRequestMatcher = driver.getMock( "RESOURCEMANAGER" ).expect().method( "GET" )
@@ -2546,12 +2545,12 @@ public class GatewayBasicFuncTest {
     if ( params != null ) {
       for (Entry<String, String> param : params.entrySet()) {
         mockRequestMatcher.queryParam( param.getKey(), param.getValue() );
-        if (gatewayPathQuery.isEmpty()) {
-          gatewayPathQuery += "?";
+        if (gatewayPathQuery.length() == 0) {
+          gatewayPathQuery.append("?");
         } else {
-          gatewayPathQuery += "&";
+          gatewayPathQuery.append("&");
         }
-        gatewayPathQuery += param.getKey() + "=" + param.getValue();
+        gatewayPathQuery.append(param.getKey()).append("=").append(param.getValue());
       }
     }
 
@@ -2660,7 +2659,7 @@ public class GatewayBasicFuncTest {
         .statusCode( HttpStatus.SC_NOT_FOUND ).when()
         .get( encryptedTrackingUrl );
 
-    String resource = null;
+    String resource;
 
     path = "/proxy/application_1399541193872_0033/ws/v1/mapreduce/info";
     resource = "yarn/proxy-mapreduce-info";
@@ -4146,8 +4145,7 @@ public class GatewayBasicFuncTest {
         .body( "boolean", CoreMatchers.equalTo(true) )
         .when()
         .put( driver.getUrl("WEBHDFS") + "/v1" + dir + ( driver.isUseGateway() ? "" : "?user.name=" + user ) );
-    String location = response.getHeader( "Location" );
-    return location;
+    return response.getHeader( "Location" );
   }
 
   private String createDir( String user, String password, String group, String dir, String permsOctal, int nnStatus, int chownStatus ) {
@@ -4413,8 +4411,7 @@ public class GatewayBasicFuncTest {
 //          .statusCode( status )
 //          .when().post( getUrl( "OOZIE" ) + "/v1/jobs" + ( isUseGateway() ? "" : "?user.name=" + user ) ).asString();
       //System.out.println( "JSON=" + json );
-    String id = JsonPath.from(json).getString( "id" );
-    return id;
+    return JsonPath.from(json).getString( "id" );
   }
 
   /* GET /oozie/v1/jobs?filter=user%3Dbansalm&offset=1&len=50 (body JSON; contains URL)
@@ -4492,8 +4489,7 @@ public class GatewayBasicFuncTest {
     HttpResponse response = client.execute( targetHost, request, context );
     assertThat( response.getStatusLine().getStatusCode(), Matchers.is(status) );
     String json = EntityUtils.toString( response.getEntity() );
-    String jobStatus = JsonPath.from(json).getString( "status" );
-    return jobStatus;
+    return JsonPath.from(json).getString( "status" );
   }
 
   /* GET /oozie/v1/job/0000000-130214094519989-oozie-oozi-W?show=definition

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test/src/test/java/org/apache/knox/gateway/GatewayDeployFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayDeployFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayDeployFuncTest.java
index 87a08a0..eef4234 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayDeployFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayDeployFuncTest.java
@@ -130,7 +130,7 @@ public class GatewayDeployFuncTest {
   }
 
   private static XMLTag createTopology() {
-    XMLTag xml = XMLDoc.newDocument( true )
+    return XMLDoc.newDocument( true )
         .addRoot( "topology" )
         .addTag( "gateway" )
 
@@ -162,7 +162,6 @@ public class GatewayDeployFuncTest {
         .addTag( "service" )
         .addTag( "role" ).addText( "test-service-role" )
         .gotoRoot();
-    return xml;
   }
 
   //@Test

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test/src/test/java/org/apache/knox/gateway/GatewayHealthFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayHealthFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayHealthFuncTest.java
index e309f0c..8fc539b 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayHealthFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayHealthFuncTest.java
@@ -131,7 +131,7 @@ public class GatewayHealthFuncTest {
   }
 
   private static XMLTag createTopology() {
-    XMLTag xml = XMLDoc.newDocument(true)
+    return XMLDoc.newDocument(true)
         .addRoot("topology")
         .addTag("gateway")
         .addTag("provider")
@@ -162,7 +162,6 @@ public class GatewayHealthFuncTest {
         .addTag("service")
         .addTag("role").addText("HEALTH")
         .gotoRoot();
-    return xml;
   }
 
   @Test(timeout = TestUtils.MEDIUM_TIMEOUT)
@@ -197,7 +196,7 @@ public class GatewayHealthFuncTest {
     //String version = JsonPath.from(body).getString("version");
     Map<String, String> hm = JsonPath.from(body).getMap("");
     Assert.assertTrue(hm.size() >= 6);
-    Assert.assertTrue(hm.keySet().containsAll(new HashSet<String>(Arrays.asList(new String[]{"timers", "histograms",
+    Assert.assertTrue(hm.keySet().containsAll(new HashSet<>(Arrays.asList(new String[]{"timers", "histograms",
         "counters", "gauges", "version", "meters"}))));
     TestUtils.LOG_EXIT();
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapDynamicGroupFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapDynamicGroupFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapDynamicGroupFuncTest.java
index 436f2ba..100b977 100755
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapDynamicGroupFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapDynamicGroupFuncTest.java
@@ -90,7 +90,8 @@ public class GatewayLdapDynamicGroupFuncTest {
   }
 
   private static XMLTag createTopology() {
-    XMLTag xml = XMLDoc.newDocument( true )
+    // System.out.println( "GATEWAY=" + xml.toString() );
+    return XMLDoc.newDocument( true )
         .addRoot( "topology" )
         .addTag( "gateway" )
 
@@ -165,8 +166,6 @@ public class GatewayLdapDynamicGroupFuncTest {
         .addTag( "service" )
         .addTag( "role" ).addText( "test-service-role" )
         .gotoRoot();
-         // System.out.println( "GATEWAY=" + xml.toString() );
-    return xml;
   }
 
   @Test( timeout = TestUtils.MEDIUM_TIMEOUT )

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapGroupFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapGroupFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapGroupFuncTest.java
index 2956ecf..a79067c 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapGroupFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapGroupFuncTest.java
@@ -83,7 +83,8 @@ public class GatewayLdapGroupFuncTest {
   }
 
   private static XMLTag createTopology() {
-    XMLTag xml = XMLDoc.newDocument( true )
+    // System.out.println( "GATEWAY=" + xml.toString() );
+    return XMLDoc.newDocument( true )
         .addRoot( "topology" )
         .addTag( "gateway" )
 
@@ -157,8 +158,6 @@ public class GatewayLdapGroupFuncTest {
         .addTag( "service" )
         .addTag( "role" ).addText( "test-service-role" )
         .gotoRoot();
-         // System.out.println( "GATEWAY=" + xml.toString() );
-    return xml;
   }
 
   @Test( timeout = TestUtils.MEDIUM_TIMEOUT )

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapPosixGroupFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapPosixGroupFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapPosixGroupFuncTest.java
index e4872ae..e627ba0 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapPosixGroupFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLdapPosixGroupFuncTest.java
@@ -87,7 +87,8 @@ public class GatewayLdapPosixGroupFuncTest {
   }
 
   private static XMLTag createTopology() {
-    XMLTag xml = XMLDoc.newDocument( true )
+
+    return XMLDoc.newDocument( true )
         .addRoot( "topology" )
         .addTag( "gateway" )
 
@@ -161,8 +162,6 @@ public class GatewayLdapPosixGroupFuncTest {
         .addTag( "service" )
         .addTag( "role" ).addText( "test-service-role" )
         .gotoRoot();
-
-    return xml;
   }
 
   @Test( timeout = TestUtils.MEDIUM_TIMEOUT )

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLocalServiceFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLocalServiceFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLocalServiceFuncTest.java
index 417c75c..955ad50 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLocalServiceFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayLocalServiceFuncTest.java
@@ -119,7 +119,8 @@ public class GatewayLocalServiceFuncTest {
   }
 
   private static XMLTag createTopology() {
-    XMLTag xml = XMLDoc.newDocument( true )
+    // System.out.println( "GATEWAY=" + xml.toString() );
+    return XMLDoc.newDocument( true )
         .addRoot( "topology" )
         .addTag( "gateway" )
         .addTag( "provider" )
@@ -150,8 +151,6 @@ public class GatewayLocalServiceFuncTest {
         .addTag( "service" )
         .addTag( "role" ).addText( "test-jersey-service-role" )
         .gotoRoot();
-    // System.out.println( "GATEWAY=" + xml.toString() );
-    return xml;
   }
 
   @Test( timeout = TestUtils.MEDIUM_TIMEOUT )

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingDisableFeatureTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingDisableFeatureTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingDisableFeatureTest.java
index 5f202c0..4d9e767 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingDisableFeatureTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingDisableFeatureTest.java
@@ -168,7 +168,7 @@ public class GatewayPortMappingDisableFeatureTest {
    * @return A populated XML structure for a topology file.
    */
   private static XMLTag createTopology(final String role) {
-    XMLTag xml = XMLDoc.newDocument(true)
+    return XMLDoc.newDocument(true)
         .addRoot("topology")
         .addTag("gateway")
         .addTag("provider")
@@ -220,7 +220,6 @@ public class GatewayPortMappingDisableFeatureTest {
         .addTag("role").addText(role)
         .addTag("url").addText("http://localhost:" + masterServer.getPort() + "/webhdfs")
         .gotoRoot();
-    return xml;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingFuncTest.java
index 81dda51..afd3e73 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingFuncTest.java
@@ -190,7 +190,7 @@ public class GatewayPortMappingFuncTest {
    * @return A populated XML structure for a topology file.
    */
   public static XMLTag createTopology(final String role, final String ldapURL, final int gatewayPort ) {
-    XMLTag xml = XMLDoc.newDocument(true)
+    return XMLDoc.newDocument(true)
         .addRoot("topology")
         .addTag("gateway")
         .addTag("provider")
@@ -242,7 +242,6 @@ public class GatewayPortMappingFuncTest {
         .addTag("role").addText(role)
         .addTag("url").addText("http://localhost:" + gatewayPort + "/webhdfs")
         .gotoRoot();
-    return xml;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test/src/test/java/org/apache/knox/gateway/GatewaySampleFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewaySampleFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewaySampleFuncTest.java
index 29e81e5..7a842cc 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewaySampleFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewaySampleFuncTest.java
@@ -117,7 +117,8 @@ public class GatewaySampleFuncTest {
   }
 
   private static XMLTag createTopology() {
-    XMLTag xml = XMLDoc.newDocument( true )
+    // System.out.println( "GATEWAY=" + xml.toString() );
+    return XMLDoc.newDocument( true )
         .addRoot( "topology" )
         .addTag( "gateway" )
         .addTag( "provider" )
@@ -148,8 +149,6 @@ public class GatewaySampleFuncTest {
         .addTag( "service" )
         .addTag( "role" ).addText( "test-service-role" )
         .gotoRoot();
-    // System.out.println( "GATEWAY=" + xml.toString() );
-    return xml;
   }
 
   //@Test

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test/src/test/java/org/apache/knox/gateway/GatewayUIFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayUIFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayUIFuncTest.java
index f51282a..0cc9606 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayUIFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayUIFuncTest.java
@@ -112,7 +112,8 @@ public class GatewayUIFuncTest {
    * @return A populated XML structure for a topology file.
    */
   private static XMLTag createTopology() {
-    XMLTag xml = XMLDoc.newDocument( true )
+    //System.out.println( "GATEWAY=" + xml.toString() );
+    return XMLDoc.newDocument( true )
         .addRoot( "topology" )
           .addTag( "gateway" )
             .addTag( "provider" )
@@ -149,8 +150,6 @@ public class GatewayUIFuncTest {
           .addTag( "service" )
             .addTag( "role" ).addText( "OOZIEUI" )
             .addTag( "url" ).addText( driver.getRealUrl( "OOZIEUI" ) ).gotoParent();
-    //System.out.println( "GATEWAY=" + xml.toString() );
-    return xml;
   }
 
   @Test( timeout = TestUtils.MEDIUM_TIMEOUT )

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test/src/test/java/org/apache/knox/gateway/Knox242FuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/Knox242FuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/Knox242FuncTest.java
index bd86f9b..c964066 100755
--- a/gateway-test/src/test/java/org/apache/knox/gateway/Knox242FuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/Knox242FuncTest.java
@@ -92,7 +92,8 @@ public class Knox242FuncTest {
   }
 
   private static XMLTag createTopology() {
-    XMLTag xml = XMLDoc.newDocument( true )
+    // System.out.println( "GATEWAY=" + xml.toString() );
+    return XMLDoc.newDocument( true )
         .addRoot( "topology" )
         .addTag( "gateway" )
 
@@ -182,8 +183,6 @@ public class Knox242FuncTest {
         .addTag( "service" )
         .addTag( "role" ).addText( "test-service-role" )
         .gotoRoot();
-         // System.out.println( "GATEWAY=" + xml.toString() );
-    return xml;
   }
 
   @Test( timeout = TestUtils.MEDIUM_TIMEOUT )

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestNegative.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestNegative.java b/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestNegative.java
index 1775196..43800be 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestNegative.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestNegative.java
@@ -127,7 +127,8 @@ public class KnoxCliLdapFuncTestNegative {
   }
 
   private static XMLTag createBadTopology(){
-    XMLTag xml = XMLDoc.newDocument(true)
+    // System.out.println( "GATEWAY=" + xml.toString() );
+    return XMLDoc.newDocument(true)
         .addRoot("topology")
         .addTag("gateway")
         .addTag( "provider" )
@@ -164,13 +165,12 @@ public class KnoxCliLdapFuncTestNegative {
         .addTag( "service" )
         .addTag( "role" ).addText( "KNOX" )
         .gotoRoot();
-    // System.out.println( "GATEWAY=" + xml.toString() );
-    return xml;
   }
 
   private static XMLTag createTopology() {
 
-    XMLTag xml = XMLDoc.newDocument(true)
+    // System.out.println( "GATEWAY=" + xml.toString() );
+    return XMLDoc.newDocument(true)
         .addRoot("topology")
         .addTag("gateway" )
         .addTag("provider")
@@ -230,8 +230,6 @@ public class KnoxCliLdapFuncTestNegative {
         .addTag( "service" )
         .addTag( "role" ).addText( "test-service-role" )
         .gotoRoot();
-    // System.out.println( "GATEWAY=" + xml.toString() );
-    return xml;
   }
 
   @Test( timeout = TestUtils.MEDIUM_TIMEOUT )

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestPositive.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestPositive.java b/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestPositive.java
index e657a52..60a6e99 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestPositive.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliLdapFuncTestPositive.java
@@ -127,7 +127,8 @@ public class KnoxCliLdapFuncTestPositive {
   }
 
   private static XMLTag createBadTopology(){
-    XMLTag xml = XMLDoc.newDocument(true)
+    // System.out.println( "GATEWAY=" + xml.toString() );
+    return XMLDoc.newDocument(true)
         .addRoot("topology")
         .addTag( "gateway" )
         .addTag("provider")
@@ -160,13 +161,12 @@ public class KnoxCliLdapFuncTestPositive {
         .addTag( "service")
         .addTag("role").addText( "KNOX" )
         .gotoRoot();
-    // System.out.println( "GATEWAY=" + xml.toString() );
-    return xml;
   }
 
   private static XMLTag createTopology() {
 
-    XMLTag xml = XMLDoc.newDocument(true)
+    // System.out.println( "GATEWAY=" + xml.toString() );
+    return XMLDoc.newDocument(true)
         .addRoot("topology")
         .addTag("gateway")
         .addTag("provider")
@@ -220,8 +220,6 @@ public class KnoxCliLdapFuncTestPositive {
         .addTag( "service" )
         .addTag( "role" ).addText( "test-service-role" )
         .gotoRoot();
-    // System.out.println( "GATEWAY=" + xml.toString() );
-    return xml;
   }
 
   @Test( timeout = TestUtils.MEDIUM_TIMEOUT )

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliSysBindTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliSysBindTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliSysBindTest.java
index 107ddbc..81376b4 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliSysBindTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/KnoxCliSysBindTest.java
@@ -131,7 +131,8 @@ public class KnoxCliSysBindTest {
   }
 
   private static XMLTag createBadTopology(){
-    XMLTag xml = XMLDoc.newDocument(true)
+    // System.out.println( "GATEWAY=" + xml.toString() );
+    return XMLDoc.newDocument(true)
         .addRoot("topology")
         .addTag( "gateway" )
         .addTag("provider")
@@ -164,13 +165,12 @@ public class KnoxCliSysBindTest {
         .addTag( "service")
         .addTag("role").addText( "KNOX" )
         .gotoRoot();
-    // System.out.println( "GATEWAY=" + xml.toString() );
-    return xml;
   }
 
   private static XMLTag createTopology(String username, String password) {
 
-    XMLTag xml = XMLDoc.newDocument(true)
+    // System.out.println( "GATEWAY=" + xml.toString() );
+    return XMLDoc.newDocument(true)
         .addRoot("topology")
         .addTag("gateway")
         .addTag("provider")
@@ -224,8 +224,6 @@ public class KnoxCliSysBindTest {
         .addTag( "service" )
         .addTag( "role" ).addText( "test-service-role" )
         .gotoRoot();
-    // System.out.println( "GATEWAY=" + xml.toString() );
-    return xml;
   }
 
   @Test( timeout = TestUtils.MEDIUM_TIMEOUT )

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test/src/test/java/org/apache/knox/gateway/WebHdfsHaFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/WebHdfsHaFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/WebHdfsHaFuncTest.java
index 2290b23..8ec4664 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/WebHdfsHaFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/WebHdfsHaFuncTest.java
@@ -96,7 +96,8 @@ public class WebHdfsHaFuncTest {
     * @return A populated XML structure for a topology file.
     */
    private static XMLTag createTopology() {
-      XMLTag xml = XMLDoc.newDocument(true)
+     //     System.out.println( "GATEWAY=" + xml.toString() );
+      return XMLDoc.newDocument(true)
             .addRoot("topology")
             .addTag("gateway")
             .addTag("provider")
@@ -149,8 +150,6 @@ public class WebHdfsHaFuncTest {
             .addTag("url").addText("http://localhost:" + masterServer.getPort() + "/webhdfs")
             .addTag("url").addText("http://localhost:" + standbyServer.getPort() + "/webhdfs").gotoParent()
             .gotoRoot();
-//     System.out.println( "GATEWAY=" + xml.toString() );
-      return xml;
    }
 
   @Test( timeout = TestUtils.MEDIUM_TIMEOUT )

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-test/src/test/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitorTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitorTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitorTest.java
index 3894a69..231ff73 100644
--- a/gateway-test/src/test/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitorTest.java
+++ b/gateway-test/src/test/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitorTest.java
@@ -404,7 +404,7 @@ public class RemoteConfigurationMonitorTest {
         RemoteConfigurationMonitor cm = RemoteConfigurationMonitorFactory.get(gc);
         assertNotNull("Failed to load RemoteConfigurationMonitor", cm);
 
-        List<ACL> acls = Arrays.asList(ANY_AUTHENTICATED_USER_ALL);
+        List<ACL> acls = Collections.singletonList(ANY_AUTHENTICATED_USER_ALL);
         client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).withACL(acls).forPath(PATH_KNOX);
         client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).withACL(acls).forPath(PATH_KNOX_CONFIG);
         client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).withACL(acls).forPath(PATH_KNOX_PROVIDERS);

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/appender/JdbmQueue.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/appender/JdbmQueue.java b/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/appender/JdbmQueue.java
index ff326f6..f9e4f56 100644
--- a/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/appender/JdbmQueue.java
+++ b/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/appender/JdbmQueue.java
@@ -74,7 +74,7 @@ public class JdbmQueue<E> {
         s = getStat();
       }
       s.nextDequeue++;
-      Long key = Long.valueOf( s.nextDequeue );
+      Long key = s.nextDequeue;
       @SuppressWarnings("unchecked")
       E e = (E)data.get( key );
       data.remove( key );
@@ -98,9 +98,7 @@ public class JdbmQueue<E> {
         db.commit();
         committed = true;
       }
-    } catch( RuntimeException e ) {
-      throw e;
-    } catch( IOException e ) {
+    } catch( RuntimeException | IOException e ) {
       throw e;
     } catch( Throwable t ) {
       throw new RuntimeException( t );

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/appender/JdbmStoreAndForwardAppender.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/appender/JdbmStoreAndForwardAppender.java b/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/appender/JdbmStoreAndForwardAppender.java
index dac9290..3aec64f 100644
--- a/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/appender/JdbmStoreAndForwardAppender.java
+++ b/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/appender/JdbmStoreAndForwardAppender.java
@@ -82,9 +82,7 @@ public class JdbmStoreAndForwardAppender extends AppenderSkeleton {
       queue.stop();
       forwarder.join();
       queue.close();
-    } catch( InterruptedException e ) {
-      throw new RuntimeException( e );
-    } catch( IOException e ) {
+    } catch( InterruptedException | IOException e ) {
       throw new RuntimeException( e );
     }
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/audit/Log4jAuditContext.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/audit/Log4jAuditContext.java b/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/audit/Log4jAuditContext.java
index 2052cf9..825a59b 100644
--- a/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/audit/Log4jAuditContext.java
+++ b/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/audit/Log4jAuditContext.java
@@ -94,16 +94,14 @@ public class Log4jAuditContext implements Serializable, AuditContext {
 
   @Override
   public String toString() {
-    StringBuilder sb = new StringBuilder();
-    sb.append( "[" );
-    sb.append( "username=" ).append( username );
-    sb.append( ", proxy_username=" ).append( proxyUsername );
-    sb.append( ", system_username=" ).append( systemUsername );
-    sb.append( ", targetServiceName=" ).append( targetServiceName );
-    sb.append( ", remoteIp=" ).append( remoteIp );
-    sb.append( ", remoteHostname=" ).append( remoteHostname );
-    sb.append( "]" );
-    return sb.toString();
+    return "[" +
+               "username=" + username +
+               ", proxy_username=" + proxyUsername +
+               ", system_username=" + systemUsername +
+               ", targetServiceName=" + targetServiceName +
+               ", remoteIp=" + remoteIp +
+               ", remoteHostname=" + remoteHostname +
+               "]";
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/audit/Log4jAuditor.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/audit/Log4jAuditor.java b/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/audit/Log4jAuditor.java
index a3594c5..a70887b 100644
--- a/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/audit/Log4jAuditor.java
+++ b/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/audit/Log4jAuditor.java
@@ -148,14 +148,14 @@ public class Log4jAuditor implements Auditor {
           !original.getQuery().isEmpty()) {
 
         final String[] query = original.getQuery().split("&");
-        final StringBuffer newQuery = new StringBuffer();
+        final StringBuilder newQuery = new StringBuilder();
 
         for(int i = 0; i < query.length; i++ ) {
 
           for(final String s: maskedParams) {
             /* mask "knoxtoken" param */
             if(query[i].contains(s+"=")) {
-              newQuery.append(s+"=***************");
+              newQuery.append(s).append("=***************");
             } else {
               newQuery.append(query[i]);
             }

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/correlation/Log4jCorrelationContext.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/correlation/Log4jCorrelationContext.java b/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/correlation/Log4jCorrelationContext.java
index 7bd9ba8..615ff34 100644
--- a/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/correlation/Log4jCorrelationContext.java
+++ b/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/log4j/correlation/Log4jCorrelationContext.java
@@ -73,13 +73,11 @@ public class Log4jCorrelationContext implements Externalizable, CorrelationConte
 
   @Override
   public String toString() {
-    StringBuilder sb = new StringBuilder();
-    sb.append( "[" );
-    sb.append( "request_id=" ).append( requestId );
-    sb.append( ", parent_request_id=" ).append( parentRequestId );
-    sb.append( ", root_request_id=" ).append( rootRequestId );
-    sb.append( "]" );
-    return sb.toString();
+    return "[" +
+               "request_id=" + requestId +
+               ", parent_request_id=" + parentRequestId +
+               ", root_request_id=" + rootRequestId +
+               "]";
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-util-common/src/main/java/org/apache/knox/gateway/util/CertificateUtils.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/main/java/org/apache/knox/gateway/util/CertificateUtils.java b/gateway-util-common/src/main/java/org/apache/knox/gateway/util/CertificateUtils.java
index dada236..ea8bc62 100644
--- a/gateway-util-common/src/main/java/org/apache/knox/gateway/util/CertificateUtils.java
+++ b/gateway-util-common/src/main/java/org/apache/knox/gateway/util/CertificateUtils.java
@@ -41,7 +41,7 @@ public class CertificateUtils {
    */
   public static RSAPublicKey parseRSAPublicKey(String pem) throws ServletException {
     String fullPem = PEM_HEADER + pem + PEM_FOOTER;
-    PublicKey key = null;
+    PublicKey key;
     try {
       CertificateFactory fact = CertificateFactory.getInstance("X.509");
       ByteArrayInputStream is = new ByteArrayInputStream(
@@ -50,7 +50,7 @@ public class CertificateUtils {
       X509Certificate cer = (X509Certificate) fact.generateCertificate(is);
       key = cer.getPublicKey();
     } catch (CertificateException ce) {
-      String message = null;
+      String message;
       if (pem.startsWith(PEM_HEADER)) {
         message = "CertificateException - be sure not to include PEM header "
             + "and footer in the PEM configuration element.";

http://git-wip-us.apache.org/repos/asf/knox/blob/f54e9d2d/gateway-util-common/src/main/java/org/apache/knox/gateway/util/HttpUtils.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/main/java/org/apache/knox/gateway/util/HttpUtils.java b/gateway-util-common/src/main/java/org/apache/knox/gateway/util/HttpUtils.java
index 8f4294c..511398c 100644
--- a/gateway-util-common/src/main/java/org/apache/knox/gateway/util/HttpUtils.java
+++ b/gateway-util-common/src/main/java/org/apache/knox/gateway/util/HttpUtils.java
@@ -40,7 +40,7 @@ public class HttpUtils {
       final int idx = pair.indexOf('=');
       final String key = idx > 0 ? URLDecoder.decode(pair.substring(0, idx), StandardCharsets.UTF_8.name()) : pair;
       if (!queryPairs.containsKey(key)) {
-        queryPairs.put(key, new ArrayList<String>());
+        queryPairs.put(key, new ArrayList<>());
       }
       final String value = idx > 0 && pair.length() > idx + 1
           ? URLDecoder.decode(pair.substring(idx + 1), StandardCharsets.UTF_8.name()) : "";


Mime
View raw message