knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kris...@apache.org
Subject [2/3] knox git commit: KNOX-1615 - Enable PMD for source analysis
Date Mon, 10 Dec 2018 18:20:21 GMT
http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/DefaultCryptoService.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/DefaultCryptoService.java b/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/DefaultCryptoService.java
index 7010d29..24487a0 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/DefaultCryptoService.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/DefaultCryptoService.java
@@ -41,11 +41,11 @@ import org.apache.knox.gateway.services.ServiceLifecycleException;
 public class DefaultCryptoService implements CryptoService {
   private static final GatewayMessages LOG = MessagesFactory.get( GatewayMessages.class );
 
-  private AliasService as = null;
-  private KeystoreService ks = null;
+  private AliasService as;
+  private KeystoreService ks;
   private HashMap<String,ConfigurableEncryptor> encryptorCache =
       new HashMap<>();
-  private GatewayConfig config = null;
+  private GatewayConfig config;
 
   public void setKeystoreService(KeystoreService ks) {
     this.ks = ks;

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/DefaultKeystoreService.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/DefaultKeystoreService.java b/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/DefaultKeystoreService.java
index e72681f..c0c6756 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/DefaultKeystoreService.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/DefaultKeystoreService.java
@@ -62,11 +62,11 @@ public class DefaultKeystoreService extends BaseKeystoreService implements
   private static GatewayMessages LOG = MessagesFactory.get( GatewayMessages.class );
   private static GatewayResources RES = ResourcesFactory.get( GatewayResources.class );
 
-  private String signingKeystoreName = null;
-  private String signingKeyAlias = null;
+  private String signingKeystoreName;
+  private String signingKeyAlias;
   private Map<String, Map<String, String>> cache = new ConcurrentHashMap<>();
-  private Lock readLock = null;
-  private Lock writeLock = null;
+  private Lock readLock;
+  private Lock writeLock;
 
   @Override
   public void init(GatewayConfig config, Map<String, String> options)

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/JettySSLService.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/JettySSLService.java b/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/JettySSLService.java
index 75613c3..b9e5c0c 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/JettySSLService.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/JettySSLService.java
@@ -17,9 +17,10 @@
  */
 package org.apache.knox.gateway.services.security.impl;
 
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.security.KeyStore;
 import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
@@ -55,9 +56,9 @@ public class JettySSLService implements SSLService {
   private MasterService ms;
   private KeystoreService ks;
   private AliasService as;
-  private List<String> sslIncludeCiphers = null;
-  private List<String> sslExcludeCiphers = null;
-  private List<String> sslExcludeProtocols = null;
+  private List<String> sslIncludeCiphers;
+  private List<String> sslExcludeCiphers;
+  private List<String> sslExcludeProtocols;
   private boolean clientAuthNeeded;
   private boolean trustAllCerts;
   private String truststorePath;
@@ -241,7 +242,7 @@ public class JettySSLService implements SSLService {
 
   private static KeyStore loadKeyStore( String fileName, String storeType, char[] storePass ) throws CertificateException, NoSuchAlgorithmException, IOException, KeyStoreException {
     KeyStore keystore = KeyStore.getInstance(storeType);
-    try (InputStream is = new FileInputStream(fileName)) {
+    try (InputStream is = Files.newInputStream(Paths.get(fileName))) {
       keystore.load(is, storePass);
     }
     return keystore;

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/main/java/org/apache/knox/gateway/services/token/impl/DefaultTokenAuthorityService.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/services/token/impl/DefaultTokenAuthorityService.java b/gateway-server/src/main/java/org/apache/knox/gateway/services/token/impl/DefaultTokenAuthorityService.java
index b32e914..b9e606f 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/services/token/impl/DefaultTokenAuthorityService.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/services/token/impl/DefaultTokenAuthorityService.java
@@ -51,9 +51,9 @@ public class DefaultTokenAuthorityService implements JWTokenAuthority, Service {
 
   private static final String SIGNING_KEY_PASSPHRASE = "signing.key.passphrase";
   private static final Set<String> SUPPORTED_SIG_ALGS = new HashSet<>();
-  private AliasService as = null;
-  private KeystoreService ks = null;
-  String signingKeyAlias = null;
+  private AliasService as;
+  private KeystoreService ks;
+  String signingKeyAlias;
 
   static {
       // Only standard RSA signature algorithms are accepted

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultClusterConfigurationMonitorService.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultClusterConfigurationMonitorService.java b/gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultClusterConfigurationMonitorService.java
index 60ee562..d3bd40a 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultClusterConfigurationMonitorService.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultClusterConfigurationMonitorService.java
@@ -30,7 +30,7 @@ import java.util.ServiceLoader;
 
 public class DefaultClusterConfigurationMonitorService implements ClusterConfigurationMonitorService {
 
-    private AliasService aliasService = null;
+    private AliasService aliasService;
 
     private Map<String, ClusterConfigurationMonitor> monitors = new HashMap<>();
 

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java b/gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java
index cdc4907..2d501f1 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java
@@ -114,7 +114,7 @@ public class DefaultTopologyService
   private volatile Map<File, Topology> topologies;
   private AliasService aliasService;
 
-  private RemoteConfigurationMonitor remoteMonitor = null;
+  private RemoteConfigurationMonitor remoteMonitor;
 
   private GatewayConfig config;
 

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/main/java/org/apache/knox/gateway/topology/discovery/DefaultServiceDiscoveryConfig.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/topology/discovery/DefaultServiceDiscoveryConfig.java b/gateway-server/src/main/java/org/apache/knox/gateway/topology/discovery/DefaultServiceDiscoveryConfig.java
index d6e3d50..52913e8 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/topology/discovery/DefaultServiceDiscoveryConfig.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/topology/discovery/DefaultServiceDiscoveryConfig.java
@@ -18,8 +18,8 @@ package org.apache.knox.gateway.topology.discovery;
 
 public class DefaultServiceDiscoveryConfig implements ServiceDiscoveryConfig {
     private String address;
-    private String user     = null;
-    private String pwdAlias = null;
+    private String user;
+    private String pwdAlias;
 
     public DefaultServiceDiscoveryConfig(String address) {
         this.address = address;

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/main/java/org/apache/knox/gateway/topology/monitor/DefaultRemoteConfigurationMonitor.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/topology/monitor/DefaultRemoteConfigurationMonitor.java b/gateway-server/src/main/java/org/apache/knox/gateway/topology/monitor/DefaultRemoteConfigurationMonitor.java
index d209d73..82242a3 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/topology/monitor/DefaultRemoteConfigurationMonitor.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/topology/monitor/DefaultRemoteConfigurationMonitor.java
@@ -103,7 +103,7 @@ class DefaultRemoteConfigurationMonitor implements RemoteConfigurationMonitor {
         };
     }
 
-    private RemoteConfigurationRegistryClient client = null;
+    private RemoteConfigurationRegistryClient client;
 
     private File providersDir;
     private File descriptorsDir;

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/main/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitorFactory.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitorFactory.java b/gateway-server/src/main/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitorFactory.java
index 07c3842..83eeed4 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitorFactory.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitorFactory.java
@@ -29,7 +29,7 @@ public class RemoteConfigurationMonitorFactory {
 
     private static final GatewayMessages log = MessagesFactory.get(GatewayMessages.class);
 
-    private static RemoteConfigurationRegistryClientService remoteConfigRegistryClientService = null;
+    private static RemoteConfigurationRegistryClientService remoteConfigRegistryClientService;
 
     public static void setClientService(RemoteConfigurationRegistryClientService clientService) {
         remoteConfigRegistryClientService = clientService;

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/ProviderConfigurationParser.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/ProviderConfigurationParser.java b/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/ProviderConfigurationParser.java
index 1408ca9..45d10c2 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/ProviderConfigurationParser.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/ProviderConfigurationParser.java
@@ -28,9 +28,9 @@ import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.file.Files;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -86,7 +86,7 @@ public class ProviderConfigurationParser {
 
 
   static ProviderConfiguration parseXML(File file) throws Exception {
-    return parseXML(new FileInputStream(file));
+    return parseXML(Files.newInputStream(file.toPath()));
   }
 
 
@@ -102,7 +102,7 @@ public class ProviderConfigurationParser {
 
 
   static ProviderConfiguration parseJSON(File file) throws IOException {
-    return parseJSON(new FileInputStream(file));
+    return parseJSON(Files.newInputStream(file.toPath()));
   }
 
 
@@ -113,7 +113,7 @@ public class ProviderConfigurationParser {
 
 
   static ProviderConfiguration parseYAML(File file) throws IOException {
-    return parseYAML(new FileInputStream(file));
+    return parseYAML(Files.newInputStream(file.toPath()));
   }
 
   static ProviderConfiguration parseYAML(InputStream in) throws IOException {

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java b/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
index 4df2cf1..84af519 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
@@ -30,7 +30,6 @@ import org.apache.knox.gateway.topology.discovery.ServiceDiscoveryFactory;
 
 import java.io.BufferedWriter;
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
@@ -38,6 +37,7 @@ import java.io.StringWriter;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -574,7 +574,7 @@ public class SimpleDescriptorHandler {
             }
             topologyDescriptor = new File(destDirectory, topologyFilename + ".xml");
 
-            try (OutputStream outputStream = new FileOutputStream(topologyDescriptor);
+            try (OutputStream outputStream = Files.newOutputStream(topologyDescriptor.toPath());
                  OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8);
                  BufferedWriter fw = new BufferedWriter(outputStreamWriter)) {
               fw.write(sw.toString());

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorImpl.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorImpl.java b/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorImpl.java
index 50092cf..535e1a9 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorImpl.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorImpl.java
@@ -49,7 +49,7 @@ class SimpleDescriptorImpl implements SimpleDescriptor {
     @JsonProperty("applications")
     private List<ApplicationImpl> applications;
 
-    private String name = null;
+    private String name;
 
     void setName(String name) {
         this.name = name;

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/main/java/org/apache/knox/gateway/topology/validation/TopologyValidator.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/topology/validation/TopologyValidator.java b/gateway-server/src/main/java/org/apache/knox/gateway/topology/validation/TopologyValidator.java
index 0b678a2..5561087 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/topology/validation/TopologyValidator.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/topology/validation/TopologyValidator.java
@@ -37,7 +37,7 @@ import org.xml.sax.SAXParseException;
 
 public class TopologyValidator {
 
-  private Collection<String> errors = null;
+  private Collection<String> errors;
   private final String filePath;
 
   public TopologyValidator(Topology t){
@@ -104,7 +104,6 @@ public class TopologyValidator {
   }
 
   public Collection<String> getTopologyErrors(){
-
     if(errors != null){
       return errors;
     }else{
@@ -115,11 +114,9 @@ public class TopologyValidator {
 
   public String getErrorString(){
     StringBuilder out = new StringBuilder();
-    out.append("");
     for(String s : getTopologyErrors()){
-      out.append(s).append("\n");
+      out.append(s).append('\n');
     }
     return out.toString();
   }
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/main/java/org/apache/knox/gateway/trace/AccessHandler.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/trace/AccessHandler.java b/gateway-server/src/main/java/org/apache/knox/gateway/trace/AccessHandler.java
index 558a739..53eef68 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/trace/AccessHandler.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/trace/AccessHandler.java
@@ -24,30 +24,28 @@ import org.eclipse.jetty.server.Response;
 import org.eclipse.jetty.util.component.AbstractLifeCycle;
 
 public class AccessHandler extends AbstractLifeCycle implements RequestLog {
-
   private static Logger log = Logger.getLogger( "org.apache.knox.gateway.access" );
 
   @Override
   public void log( Request request, Response response ) {
     if( log.isTraceEnabled() ) {
       StringBuilder sb = new StringBuilder();
-      TraceUtil.appendCorrelationContext( sb );
-      sb.append( "|" );
-      sb.append( request.getRemoteAddr() );
-      sb.append( "|" );
-      sb.append( request.getMethod() );
-      sb.append( "|" );
-      sb.append( request.getHttpURI() );
-      sb.append( "|" );
-      sb.append( request.getContentLength() );
-      sb.append( "|" );
-      sb.append( response.getStatus() );
-      sb.append( "|" );
-      sb.append( response.getContentCount() );
-      sb.append( "|" );
-      sb.append( System.currentTimeMillis() - request.getTimeStamp() );
-      log.trace( sb );
+      TraceUtil.appendCorrelationContext(sb);
+      sb.append('|')
+          .append(request.getRemoteAddr())
+          .append('|')
+          .append(request.getMethod())
+          .append('|')
+          .append(request.getHttpURI())
+          .append('|')
+          .append(request.getContentLength())
+          .append('|')
+          .append(response.getStatus())
+          .append('|')
+          .append(response.getContentCount())
+          .append('|')
+          .append(System.currentTimeMillis() - request.getTimeStamp());
+      log.trace(sb);
     }
   }
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceRequest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceRequest.java b/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceRequest.java
index e40ef98..a48501e 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceRequest.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceRequest.java
@@ -55,17 +55,16 @@ class TraceRequest extends HttpServletRequestWrapper {
   private void traceRequestDetails() {
     StringBuilder sb = new StringBuilder();
     TraceUtil.appendCorrelationContext( sb );
-    sb.append( "|Request=" );
-    sb.append( getMethod() );
-    sb.append( " " );
-    sb.append( getRequestURI() );
+    sb.append("|Request=")
+        .append(getMethod())
+        .append(' ')
+        .append(getRequestURI());
     String qs = getQueryString();
     if( qs != null ) {
-      sb.append( "?" );
-      sb.append( qs );
+      sb.append('?').append(qs);
     }
-    appendHeaders( sb );
-    log.trace( sb.toString() );
+    appendHeaders(sb);
+    log.trace(sb.toString());
   }
 
   private void appendHeaders( StringBuilder sb ) {
@@ -81,5 +80,4 @@ class TraceRequest extends HttpServletRequestWrapper {
       }
     }
   }
-
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceResponse.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceResponse.java b/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceResponse.java
index e954338..8605199 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceResponse.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceResponse.java
@@ -57,8 +57,8 @@ class TraceResponse extends HttpServletResponseWrapper {
   private void traceResponseDetails() {
     StringBuilder sb = new StringBuilder();
     TraceUtil.appendCorrelationContext( sb );
-    sb.append( "|Response=" );
-    sb.append( getStatus() );
+    sb.append( "|Response=" )
+        .append( getStatus() );
     appendHeaders( sb );
     log.trace( sb.toString() );
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceUtil.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceUtil.java b/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceUtil.java
index c7f0c6b..d3fda4e 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceUtil.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/trace/TraceUtil.java
@@ -35,9 +35,9 @@ public class TraceUtil {
       sb.append( "||" );
     } else {
       append( sb, cc.getRootRequestId() );
-      sb.append( "|" );
+      sb.append('|');
       append( sb, cc.getParentRequestId() );
-      sb.append( "|" );
+      sb.append('|');
       append( sb, cc.getRequestId() );
     }
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/main/java/org/apache/knox/gateway/util/KnoxCLI.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/util/KnoxCLI.java b/gateway-server/src/main/java/org/apache/knox/gateway/util/KnoxCLI.java
index 2fae90e..6355d5e 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/util/KnoxCLI.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/util/KnoxCLI.java
@@ -119,24 +119,24 @@ public class KnoxCLI extends Configured implements Tool {
 
   private static GatewayServices services = new CLIGatewayServices();
   private Command command;
-  private String value = null;
-  private String cluster = null;
-  private String path = null;
+  private String value;
+  private String cluster;
+  private String path;
   private String generate = "false";
-  private String hostname = null;
-  private String port = null;
-  private boolean force = false;
-  private boolean debug = false;
-  private String user = null;
-  private String pass = null;
-  private boolean groups = false;
+  private String hostname;
+  private String port;
+  private boolean force;
+  private boolean debug;
+  private String user;
+  private String pass;
+  private boolean groups;
 
-  private String remoteRegistryClient = null;
-  private String remoteRegistryEntryName = null;
+  private String remoteRegistryClient;
+  private String remoteRegistryEntryName;
 
   // For testing only
-  private String master = null;
-  private String type = null;
+  private String master;
+  private String type;
 
   @Override
   public int run(String[] args) throws Exception {
@@ -1056,8 +1056,8 @@ public class KnoxCLI extends Configured implements Tool {
 
     public static final String USAGE = "ldap-command";
     public static final String DESC = "This is an internal command. It should not be used.";
-    protected String username = null;
-    protected char[] password = null;
+    protected String username;
+    protected char[] password;
     protected static final String debugMessage = "For more information use --d for debug output.";
     protected Topology topology;
 
@@ -1637,7 +1637,7 @@ public class KnoxCLI extends Configured implements Tool {
                         "Errors are reported and suggestions to resolve any problems are returned. JSON formatted.\n";
 
     private boolean ssl = true;
-    private int attempts = 0;
+    private int attempts;
 
     @Override
     public String getUsage() { return USAGE + ":\n\n" + DESC; }
@@ -1888,7 +1888,7 @@ public class KnoxCLI extends Configured implements Tool {
    * Base class for remote config registry upload commands
    */
   public abstract class RemoteRegistryUploadCommand extends RemoteRegistryCommand {
-    private File sourceFile = null;
+    private File sourceFile;
     protected String filename;
 
     protected RemoteRegistryUploadCommand(String sourceFileName) {

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/main/java/org/apache/knox/gateway/util/ServiceDefinitionsLoader.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/util/ServiceDefinitionsLoader.java b/gateway-server/src/main/java/org/apache/knox/gateway/util/ServiceDefinitionsLoader.java
index 63283cb..fad219b 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/util/ServiceDefinitionsLoader.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/util/ServiceDefinitionsLoader.java
@@ -32,13 +32,13 @@ import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Unmarshaller;
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
@@ -58,7 +58,7 @@ public class ServiceDefinitionsLoader {
         Unmarshaller unmarshaller = context.createUnmarshaller();
 
         for ( File file : getFileList(servicesDir) ) {
-          try (InputStream inputStream = new FileInputStream(file)) {
+          try (InputStream inputStream = Files.newInputStream(file.toPath())) {
             ServiceDefinition definition = (ServiceDefinition) unmarshaller.unmarshal(inputStream);
             //look for rewrite rules as a sibling (for now)
             UrlRewriteRulesDescriptor rewriteRulesDescriptor = loadRewriteRules(file.getParentFile());
@@ -119,7 +119,7 @@ public class ServiceDefinitionsLoader {
   public static UrlRewriteRulesDescriptor loadRewriteRules(File servicesDir) {
     File rewriteFile = new File(servicesDir, REWRITE_FILE);
     if ( rewriteFile.exists() ) {
-      try (InputStream stream = new FileInputStream(rewriteFile);
+      try (InputStream stream = Files.newInputStream(rewriteFile.toPath());
            Reader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) {
         return UrlRewriteRulesDescriptorFactory.load("xml", reader);
       } catch ( FileNotFoundException e ) {

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/main/java/org/apache/knox/gateway/websockets/GatewayWebsocketHandler.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/websockets/GatewayWebsocketHandler.java b/gateway-server/src/main/java/org/apache/knox/gateway/websockets/GatewayWebsocketHandler.java
index 1e8e8a9..ec97e5f 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/websockets/GatewayWebsocketHandler.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/websockets/GatewayWebsocketHandler.java
@@ -195,8 +195,8 @@ public class GatewayWebsocketHandler extends WebSocketHandler
                 || serviceUrl.getProtocol().equals("wss")) ? serviceUrl.getProtocol()
                 : "ws";
         backend.append(protocol).append("://");
-        backend.append(serviceUrl.getHost()).append(":");
-        backend.append(serviceUrl.getPort()).append("/");
+        backend.append(serviceUrl.getHost()).append(':');
+        backend.append(serviceUrl.getPort()).append('/');
         backend.append(serviceUrl.getPath());
       }
       else {

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/test/java/org/apache/knox/gateway/jetty/SslSocketTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/jetty/SslSocketTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/jetty/SslSocketTest.java
index a3cd6cd..e4e0d35 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/jetty/SslSocketTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/jetty/SslSocketTest.java
@@ -64,7 +64,7 @@ public class SslSocketTest {
 
   public class SslServer implements Runnable {
 
-    private boolean ready = false;
+    private boolean ready;
 
     public boolean waitUntilReady() throws InterruptedException {
       synchronized( this ) {

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/test/java/org/apache/knox/gateway/services/security/CryptoServiceTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/services/security/CryptoServiceTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/services/security/CryptoServiceTest.java
index c28dcaa..3204630 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/services/security/CryptoServiceTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/services/security/CryptoServiceTest.java
@@ -38,8 +38,8 @@ import static org.junit.Assert.assertEquals;
 
 @Category( { ManualTests.class, MediumTests.class } )
 public class CryptoServiceTest {
-  private static CryptoService cs = null;
-  private static AliasService as = null;
+  private static CryptoService cs;
+  private static AliasService as;
 
   @BeforeClass
   public static void setupSuite() throws Exception {

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/ProviderConfigurationParserTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/ProviderConfigurationParserTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/ProviderConfigurationParserTest.java
index b8c8f3c..50d2e52 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/ProviderConfigurationParserTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/ProviderConfigurationParserTest.java
@@ -38,7 +38,7 @@ import static org.junit.Assert.assertTrue;
 
 public class ProviderConfigurationParserTest {
 
-  private static File tmpDir = null;
+  private static File tmpDir;
 
   @BeforeClass
   public static void createTempDir() {

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/ProxyInboundClientTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/ProxyInboundClientTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/ProxyInboundClientTest.java
index a56ea49..c445254 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/ProxyInboundClientTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/ProxyInboundClientTest.java
@@ -50,9 +50,9 @@ public class ProxyInboundClientTest {
   private static URI serverUri;
   private static Handler handler;
 
-  String recievedMessage = null;
+  String recievedMessage;
 
-  byte[] recievedBinaryMessage = null;
+  byte[] recievedBinaryMessage;
 
 
   /* create an instance */

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketClient.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketClient.java b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketClient.java
index 08ac45f..6cb9cd1 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketClient.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketClient.java
@@ -40,14 +40,14 @@ import org.eclipse.jetty.util.BlockingArrayQueue;
 @ClientEndpoint
 public class WebsocketClient {
 
-  private Session session = null;
-  public CloseReason close = null;
+  private Session session;
+  public CloseReason close;
   public MessageQueue messageQueue = new MessageQueue();
   public LinkedList<Throwable> errors = new LinkedList<>();
   public CountDownLatch closeLatch = new CountDownLatch(1);
 
-  public boolean onError = false;
-  public String errorMessage = null;
+  public boolean onError;
+  public String errorMessage;
 
   @OnClose
   public void onWebSocketClose(CloseReason reason) {

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/TopologiesResource.java
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/TopologiesResource.java b/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/TopologiesResource.java
index b9e0e00..463b86b 100644
--- a/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/TopologiesResource.java
+++ b/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/TopologiesResource.java
@@ -553,10 +553,7 @@ public class TopologiesResource {
     }else{
       gatewayPath = "gateway";
     }
-    uri += "/" + gatewayPath;
-
-    uri += "/" + topology.getName();
-    return uri;
+    return uri + "/" + gatewayPath + "/" + topology.getName();
   }
 
   String buildHref(HttpServletRequest req) {
@@ -564,20 +561,20 @@ public class TopologiesResource {
   }
 
   String buildHref(String id, HttpServletRequest req) {
-    String href = buildXForwardBaseURL(req);
+    StringBuilder href = new StringBuilder(buildXForwardBaseURL(req));
     // Make sure that the pathInfo doesn't have any '/' chars at the end.
     String pathInfo = req.getPathInfo();
     while(pathInfo.endsWith("/")) {
       pathInfo = pathInfo.substring(0, pathInfo.length() - 1);
     }
 
-    href += pathInfo;
+    href.append(pathInfo);
 
     if (id != null) {
-      href += "/" + id;
+      href.append('/').append(id);
     }
 
-    return href;
+    return href.toString();
   }
 
    String buildHref(org.apache.knox.gateway.topology.Topology t, HttpServletRequest req) {
@@ -598,43 +595,43 @@ public class TopologiesResource {
     final String X_Forwarded_Port = X_Forwarded + "Port";
     final String X_Forwarded_Server = X_Forwarded + "Server";
 
-    String baseURL = "";
+    StringBuilder baseURL = new StringBuilder();
 
     // Get Protocol
     if(req.getHeader(X_Forwarded_Proto) != null){
-      baseURL += req.getHeader(X_Forwarded_Proto) + "://";
+      baseURL.append(req.getHeader(X_Forwarded_Proto)).append("://");
     } else {
-      baseURL += req.getProtocol() + "://";
+      baseURL.append(req.getProtocol()).append("://");
     }
 
     // Handle Server/Host and Port Here
     if (req.getHeader(X_Forwarded_Host) != null && req.getHeader(X_Forwarded_Port) != null){
       // Double check to see if host has port
       if(req.getHeader(X_Forwarded_Host).contains(req.getHeader(X_Forwarded_Port))){
-        baseURL += req.getHeader(X_Forwarded_Host);
+        baseURL.append(req.getHeader(X_Forwarded_Host));
       } else {
         // If there's no port, add the host and port together;
-        baseURL += req.getHeader(X_Forwarded_Host) + ":" + req.getHeader(X_Forwarded_Port);
+        baseURL.append(req.getHeader(X_Forwarded_Host)).append(':').append(req.getHeader(X_Forwarded_Port));
       }
     } else if(req.getHeader(X_Forwarded_Server) != null && req.getHeader(X_Forwarded_Port) != null){
       // Tack on the server and port if they're available. Try host if server not available
-      baseURL += req.getHeader(X_Forwarded_Server) + ":" + req.getHeader(X_Forwarded_Port);
+      baseURL.append(req.getHeader(X_Forwarded_Server)).append(':').append(req.getHeader(X_Forwarded_Port));
     } else if(req.getHeader(X_Forwarded_Port) != null) {
       // if we at least have a port, we can use it.
-      baseURL += req.getServerName() + ":" + req.getHeader(X_Forwarded_Port);
+      baseURL.append(req.getServerName()).append(':').append(req.getHeader(X_Forwarded_Port));
     } else {
       // Resort to request members
-      baseURL += req.getServerName() + ":" + req.getLocalPort();
+      baseURL.append(req.getServerName()).append(':').append(req.getLocalPort());
     }
 
     // Handle Server context
     if( req.getHeader(X_Forwarded_Context) != null ) {
-      baseURL += req.getHeader( X_Forwarded_Context );
+      baseURL.append(req.getHeader( X_Forwarded_Context ));
     } else {
-      baseURL += req.getContextPath();
+      baseURL.append(req.getContextPath());
     }
 
-    return baseURL;
+    return baseURL.toString();
   }
 
 

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-service-definitions/src/main/java/org/apache/knox/gateway/service/definition/CustomDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/src/main/java/org/apache/knox/gateway/service/definition/CustomDispatch.java b/gateway-service-definitions/src/main/java/org/apache/knox/gateway/service/definition/CustomDispatch.java
index 5091aed..35ed198 100644
--- a/gateway-service-definitions/src/main/java/org/apache/knox/gateway/service/definition/CustomDispatch.java
+++ b/gateway-service-definitions/src/main/java/org/apache/knox/gateway/service/definition/CustomDispatch.java
@@ -33,7 +33,7 @@ public class CustomDispatch {
 
   private String httpClientFactory;
 
-  private boolean useTwoWaySsl = false;
+  private boolean useTwoWaySsl;
 
   @XmlAttribute(name = "contributor-name")
   public String getContributorName() {

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-service-hive/src/main/java/org/apache/knox/gateway/hive/HiveDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-service-hive/src/main/java/org/apache/knox/gateway/hive/HiveDispatch.java b/gateway-service-hive/src/main/java/org/apache/knox/gateway/hive/HiveDispatch.java
index 4ddbe46..97dc8c1 100644
--- a/gateway-service-hive/src/main/java/org/apache/knox/gateway/hive/HiveDispatch.java
+++ b/gateway-service-hive/src/main/java/org/apache/knox/gateway/hive/HiveDispatch.java
@@ -27,7 +27,7 @@ import org.apache.http.client.methods.HttpUriRequest;
  * default HttpClientDispatch.
  */
 public class HiveDispatch extends DefaultDispatch {
-  private boolean basicAuthPreemptive = false;
+  private boolean basicAuthPreemptive;
 
   @Override
   public void init() {

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-service-hive/src/main/java/org/apache/knox/gateway/hive/HiveHaDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-service-hive/src/main/java/org/apache/knox/gateway/hive/HiveHaDispatch.java b/gateway-service-hive/src/main/java/org/apache/knox/gateway/hive/HiveHaDispatch.java
index 9403a2c..f60b324 100644
--- a/gateway-service-hive/src/main/java/org/apache/knox/gateway/hive/HiveHaDispatch.java
+++ b/gateway-service-hive/src/main/java/org/apache/knox/gateway/hive/HiveHaDispatch.java
@@ -25,7 +25,7 @@ import org.apache.http.client.methods.HttpUriRequest;
 
 public class HiveHaDispatch extends DefaultHaDispatch {
 
-  private boolean basicAuthPreemptive = false;
+  private boolean basicAuthPreemptive;
 
   public HiveHaDispatch() {
     setServiceRole("HIVE");

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-service-knoxsso/src/main/java/org/apache/knox/gateway/service/knoxsso/WebSSOResource.java
----------------------------------------------------------------------
diff --git a/gateway-service-knoxsso/src/main/java/org/apache/knox/gateway/service/knoxsso/WebSSOResource.java b/gateway-service-knoxsso/src/main/java/org/apache/knox/gateway/service/knoxsso/WebSSOResource.java
index ab3702b..04bc9bd 100644
--- a/gateway-service-knoxsso/src/main/java/org/apache/knox/gateway/service/knoxsso/WebSSOResource.java
+++ b/gateway-service-knoxsso/src/main/java/org/apache/knox/gateway/service/knoxsso/WebSSOResource.java
@@ -85,17 +85,17 @@ public class WebSSOResource {
   private static final long TOKEN_TTL_DEFAULT = 30000L;
   static final String RESOURCE_PATH = "/api/v1/websso";
   private static KnoxSSOMessages log = MessagesFactory.get( KnoxSSOMessages.class );
-  private String cookieName = null;
+  private String cookieName;
   private boolean secureOnly = true;
   private int maxAge = -1;
   private long tokenTTL = TOKEN_TTL_DEFAULT;
-  private String whitelist = null;
-  private String domainSuffix = null;
+  private String whitelist;
+  private String domainSuffix;
   private List<String> targetAudiences = new ArrayList<>();
-  private boolean enableSession = false;
+  private boolean enableSession;
   private String signatureAlgorithm = "RS256";
   private List<String> ssoExpectedparams = new ArrayList<>();
-  private String clusterName = null;
+  private String clusterName;
 
   @Context
   HttpServletRequest request;
@@ -300,20 +300,20 @@ public class WebSSOResource {
           && !ssoExpectedparams.contains(entry.getKey())) {
 
         if(first) {
-          buf.append("?");
+          buf.append('?');
           first = false;
         }
 
-        buf.append("&").append(entry.getKey());
+        buf.append('&').append(entry.getKey());
         String[] values = entry.getValue();
         if (values.length > 0 && values[0] != null) {
-          buf.append("=");
+          buf.append('=');
         }
         for (int i = 0; i < values.length; i++) {
           if (values[0] != null) {
             buf.append(values[i]);
             if (i < values.length-1) {
-              buf.append("&").append(entry.getKey()).append("=");
+              buf.append('&').append(entry.getKey()).append('=');
             }
           }
         }

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-service-knoxssout/src/main/java/org/apache/knox/gateway/service/knoxsso/WebSSOutResource.java
----------------------------------------------------------------------
diff --git a/gateway-service-knoxssout/src/main/java/org/apache/knox/gateway/service/knoxsso/WebSSOutResource.java b/gateway-service-knoxssout/src/main/java/org/apache/knox/gateway/service/knoxsso/WebSSOutResource.java
index 4b20f9b..1520968 100644
--- a/gateway-service-knoxssout/src/main/java/org/apache/knox/gateway/service/knoxsso/WebSSOutResource.java
+++ b/gateway-service-knoxssout/src/main/java/org/apache/knox/gateway/service/knoxsso/WebSSOutResource.java
@@ -46,7 +46,7 @@ public class WebSSOutResource {
 
   static final String RESOURCE_PATH = "/api/v1/webssout";
 
-  private String cookieName = null;
+  private String cookieName;
 
   @Context
   HttpServletRequest request;

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java
----------------------------------------------------------------------
diff --git a/gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java b/gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java
index 9371c4a..1c35668 100644
--- a/gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java
+++ b/gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java
@@ -62,10 +62,10 @@ public class TokenResource {
   private static TokenServiceMessages log = MessagesFactory.get( TokenServiceMessages.class );
   private long tokenTTL = TOKEN_TTL_DEFAULT;
   private List<String> targetAudiences = new ArrayList<>();
-  private String tokenTargetUrl = null;
-  private Map<String,Object> tokenClientDataMap = null;
+  private String tokenTargetUrl;
+  private Map<String,Object> tokenClientDataMap;
   private ArrayList<String> allowedDNs = new ArrayList<>();
-  private boolean clientCertRequired = false;
+  private boolean clientCertRequired;
   private String signatureAlgorithm = "RS256";
 
   @Context

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-service-remoteconfig/src/main/java/org/apache/knox/gateway/service/config/remote/zk/CuratorClientService.java
----------------------------------------------------------------------
diff --git a/gateway-service-remoteconfig/src/main/java/org/apache/knox/gateway/service/config/remote/zk/CuratorClientService.java b/gateway-service-remoteconfig/src/main/java/org/apache/knox/gateway/service/config/remote/zk/CuratorClientService.java
index b419c9c..b779e67 100644
--- a/gateway-service-remoteconfig/src/main/java/org/apache/knox/gateway/service/config/remote/zk/CuratorClientService.java
+++ b/gateway-service-remoteconfig/src/main/java/org/apache/knox/gateway/service/config/remote/zk/CuratorClientService.java
@@ -64,7 +64,7 @@ class CuratorClientService implements ZooKeeperClientService {
 
     private Map<String, RemoteConfigurationRegistryClient> clients = new HashMap<>();
 
-    private AliasService aliasService = null;
+    private AliasService aliasService;
 
 
     @Override

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMHaBaseDispatcher.java
----------------------------------------------------------------------
diff --git a/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMHaBaseDispatcher.java b/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMHaBaseDispatcher.java
index e3770ed..caec73a 100644
--- a/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMHaBaseDispatcher.java
+++ b/gateway-service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMHaBaseDispatcher.java
@@ -41,8 +41,8 @@ class  RMHaBaseDispatcher extends DefaultDispatch {
     private static final RMMessages LOG = MessagesFactory.get(RMMessages.class);
     private int maxFailoverAttempts = HaServiceConfigConstants.DEFAULT_MAX_FAILOVER_ATTEMPTS;
     private int failoverSleep = HaServiceConfigConstants.DEFAULT_FAILOVER_SLEEP;
-    private String resourceRole = null;
-    private HttpResponse inboundResponse = null;
+    private String resourceRole;
+    private HttpResponse inboundResponse;
 
     /**
      *

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/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 b169e95..5e6e0f2 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
@@ -20,10 +20,10 @@ package org.apache.knox.gateway.service.test;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.utils.URIBuilder;
-import org.apache.http.conn.ssl.SSLContexts;
 import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
+import org.apache.http.ssl.SSLContexts;
 import org.apache.knox.gateway.config.GatewayConfig;
 import org.apache.knox.gateway.services.GatewayServices;
 import org.apache.knox.gateway.services.topology.TopologyService;
@@ -218,43 +218,43 @@ public class ServiceTestResource {
     final String X_Forwarded_Port = X_Forwarded + "Port";
     final String X_Forwarded_Server = X_Forwarded + "Server";
 
-    String baseURL = "";
+    StringBuilder baseURL = new StringBuilder();
 
 //    Get Protocol
     if(req.getHeader(X_Forwarded_Proto) != null){
-      baseURL += req.getHeader(X_Forwarded_Proto) + "://";
+      baseURL.append(req.getHeader(X_Forwarded_Proto)).append("://");
     } else {
-      baseURL += req.getProtocol() + "://";
+      baseURL.append(req.getProtocol()).append("://");
     }
 
 //    Handle Server/Host and Port Here
     if (req.getHeader(X_Forwarded_Host) != null && req.getHeader(X_Forwarded_Port) != null){
 //        Double check to see if host has port
       if(req.getHeader(X_Forwarded_Host).contains(req.getHeader(X_Forwarded_Port))){
-        baseURL += req.getHeader(X_Forwarded_Host);
+        baseURL.append(req.getHeader(X_Forwarded_Host));
       } else {
 //        If there's no port, add the host and port together;
-        baseURL += req.getHeader(X_Forwarded_Host) + ":" + req.getHeader(X_Forwarded_Port);
+        baseURL.append(req.getHeader(X_Forwarded_Host)).append(':').append(req.getHeader(X_Forwarded_Port));
       }
     } else if(req.getHeader(X_Forwarded_Server) != null && req.getHeader(X_Forwarded_Port) != null){
 //      Tack on the server and port if they're available. Try host if server not available
-      baseURL += req.getHeader(X_Forwarded_Server) + ":" + req.getHeader(X_Forwarded_Port);
+      baseURL.append(req.getHeader(X_Forwarded_Server)).append(':').append(req.getHeader(X_Forwarded_Port));
     } else if(req.getHeader(X_Forwarded_Port) != null) {
 //      if we at least have a port, we can use it.
-      baseURL += req.getServerName() + ":" + req.getHeader(X_Forwarded_Port);
+      baseURL.append(req.getServerName()).append(':').append(req.getHeader(X_Forwarded_Port));
     } else {
 //      Resort to request members
-      baseURL += req.getServerName() + ":" + req.getLocalPort();
+      baseURL.append(req.getServerName()).append(':').append(req.getLocalPort());
     }
 
 //    Handle Server context
     if( req.getHeader(X_Forwarded_Context) != null ) {
-      baseURL += req.getHeader( X_Forwarded_Context );
+      baseURL.append(req.getHeader( X_Forwarded_Context ));
     } else {
-      baseURL += req.getContextPath();
+      baseURL.append(req.getContextPath());
     }
 
-    return baseURL;
+    return baseURL.toString();
   }
 
   String buildURI(Topology topology, GatewayConfig config, HttpServletRequest req){
@@ -270,10 +270,7 @@ public class ServiceTestResource {
     }else{
       gatewayPath = "gateway";
     }
-    uri += "/" + gatewayPath;
-
-    uri += "/" + topology.getName();
-    return uri;
+    return uri + "/" + gatewayPath + "/" + topology.getName();
   }
 
   @XmlAccessorType(XmlAccessType.NONE)
@@ -340,7 +337,6 @@ public class ServiceTestResource {
     }
 
     public void setMessage(String msg) {
-
       if(httpCode != -1) {
         message = buildMessage(httpCode);
       } else {
@@ -353,38 +349,25 @@ public class ServiceTestResource {
     }
 
     static String buildMessage(int code) {
-
-      String message = "";
-
       switch (code) {
-
         case 200:
-          message += "Request sucessful.";
-          break;
+          return "Request successful.";
         case 400:
-          message += "Could not properly intepret HTTP request.";
-          break;
+          return "Could not properly interpret HTTP request.";
         case 401:
-          message += "User was not authorized. Try using credentials with access to all services. " +
-              "Ensure LDAP server is running.";
-          break;
+          return "User was not authorized. Try using credentials with access to all services. " +
+                     "Ensure LDAP server is running.";
         case 403:
-          message += "Access to this resource is forbidden. It seems we might have made a bad request.";
-          break;
+          return "Access to this resource is forbidden. It seems we might have made a bad request.";
         case 404:
-          message += "The page could not be found. Are the URLs for the topology services correct?";
-          break;
+          return "The page could not be found. Are the URLs for the topology services correct?";
         case 500:
-          message += "The server encountered an error. Are all of the cluster's services running? \n" +
+          return "The server encountered an error. Are all of the cluster's services running? \n" +
               "Can a connection be established without Knox?";
-          break;
-
+        default:
+          return "";
       }
-      return message;
-
     }
-
-
   }
 
   @XmlAccessorType(XmlAccessType.FIELD)
@@ -414,8 +397,5 @@ public class ServiceTestResource {
     public void setMessages(List<String> messages){
       this.messages = messages;
     }
-
   }
-
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/BasicResponse.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/BasicResponse.java b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/BasicResponse.java
index d7e3b50..49b16ee 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/BasicResponse.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/BasicResponse.java
@@ -28,7 +28,7 @@ import java.io.InputStream;
 public class BasicResponse implements Closeable {
 
   private HttpResponse response;
-  private boolean consumed = false;
+  private boolean consumed;
   private String string;
   private InputStream stream;
   private byte[] bytes;

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/ErrorResponse.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/ErrorResponse.java b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/ErrorResponse.java
index 28a2e50..92661e9 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/ErrorResponse.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/ErrorResponse.java
@@ -24,7 +24,7 @@ class ErrorResponse extends RuntimeException {
   HttpResponse response;
 
   ErrorResponse( HttpResponse response ) {
-    super( "" + response.getStatusLine() );
+    super(String.valueOf(response.getStatusLine()));
     this.response = response;
   }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/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 f475a42..e761450 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
@@ -56,13 +56,13 @@ import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
 import java.io.Closeable;
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.nio.file.Files;
 import java.security.GeneralSecurityException;
 import java.security.KeyStore;
 import java.security.KeyStoreException;
@@ -91,7 +91,7 @@ public class KnoxSession implements Closeable {
   private static final String DEFAULT_JAAS_FILE = "/jaas.conf";
   public static final String JGSS_LOGIN_MOUDLE = "com.sun.security.jgss.initiate";
 
-  private boolean isKerberos = false;
+  private boolean isKerberos;
 
   String base;
   HttpHost host;
@@ -324,7 +324,7 @@ public class KnoxSession implements Closeable {
       }
 
       if (file.exists()) {
-        try (InputStream is = new FileInputStream(file)) {
+        try (InputStream is = Files.newInputStream(file.toPath())) {
           ks.load(is, truststorePass.toCharArray());
         }
       }

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/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 fa8b727..07f213e 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
@@ -23,10 +23,10 @@ import org.apache.knox.gateway.util.JsonUtils;
 
 import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.OutputStream;
 import java.io.PrintStream;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
@@ -57,7 +57,7 @@ public class KnoxSh {
   public PrintStream err = System.err;
 
   private Command command;
-  private String gateway = null;
+  private String gateway;
 
   public int run(String[] args) throws Exception {
     int exitCode;
@@ -184,7 +184,7 @@ public class KnoxSh {
         displayTokenDetails(json);
 
         File tokenfile = new File(System.getProperty("user.home"), ".knoxtokencache");
-        try( FileOutputStream fos = new FileOutputStream(tokenfile) ) {
+        try( OutputStream fos = Files.newOutputStream(tokenfile.toPath()) ) {
           fos.write(text.getBytes(StandardCharsets.UTF_8));
           Set<PosixFilePermission> perms = new HashSet<>();
           //add owners permission only
@@ -273,7 +273,9 @@ public class KnoxSh {
   }
 
   private String readFile(String file) throws IOException {
-    try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
+    try (InputStream inputStream = Files.newInputStream(Paths.get(file));
+         InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
+         BufferedReader reader = new BufferedReader(inputStreamReader)) {
       String line;
       StringBuilder stringBuilder = new StringBuilder();
       String ls = System.getProperty("line.separator");
@@ -283,7 +285,7 @@ public class KnoxSh {
       }
       return stringBuilder.toString();
     }
-}
+  }
 
   /**
    * @param args command line arguments

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxTokenCredentialCollector.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxTokenCredentialCollector.java b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxTokenCredentialCollector.java
index 71fe605..a9607dc 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxTokenCredentialCollector.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxTokenCredentialCollector.java
@@ -35,9 +35,9 @@ public class KnoxTokenCredentialCollector extends AbstractCredentialCollector {
 
   private static final String KNOXTOKENCACHE = ".knoxtokencache";
 
-  private String targetUrl = null;
+  private String targetUrl;
 
-  private String tokenType = null;
+  private String tokenType;
 
   @Override
   public void collect() throws CredentialCollectionException {

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hbase/table/row/DeleteRows.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hbase/table/row/DeleteRows.java b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hbase/table/row/DeleteRows.java
index ee8d7d1..58591a5 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hbase/table/row/DeleteRows.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hbase/table/row/DeleteRows.java
@@ -70,7 +70,7 @@ public class DeleteRows {
           if( column != null ) {
             columnsURIPart.append( column.toURIPart() );
           }
-          columnsURIPart.append( "/" );
+          columnsURIPart.append('/');
 
           String timeURIPart = "";
           if( time != null ) {

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hbase/table/row/QueryRows.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hbase/table/row/QueryRows.java b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hbase/table/row/QueryRows.java
index 7686520..a272921 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hbase/table/row/QueryRows.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hbase/table/row/QueryRows.java
@@ -90,17 +90,17 @@ public class QueryRows {
           int index = 0;
           for( Column column : columns ) {
             if( index++ > 0 ) {
-              columnsURIPart.append( "," );
+              columnsURIPart.append(',');
             }
             columnsURIPart.append( column.toURIPart() );
           }
-          columnsURIPart.append( "/" );
+          columnsURIPart.append('/');
 
           StringBuilder timesURIPart = new StringBuilder();
           if( startTime != null && endTime != null ) {
-            timesURIPart.append( startTime ).append( "," ).append( endTime );
+            timesURIPart.append( startTime ).append(',').append( endTime );
           } else if( startTime != null ) {
-            timesURIPart.append( startTime ).append( "," ).append( Long.MAX_VALUE );
+            timesURIPart.append( startTime ).append(',').append( Long.MAX_VALUE );
           } else if( endTime != null ) {
             timesURIPart.append( endTime );
           }

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hdfs/Mkdir.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hdfs/Mkdir.java b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hdfs/Mkdir.java
index d4aaab7..f927953 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hdfs/Mkdir.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hdfs/Mkdir.java
@@ -30,8 +30,8 @@ class Mkdir {
 
   public static class Request extends AbstractRequest<Response> {
 
-    String dir = null;
-    String perm = null;
+    String dir;
+    String perm;
 
     Request( KnoxSession session ) {
       super( session );

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hdfs/Put.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hdfs/Put.java b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hdfs/Put.java
index f48b40b..9d6e74e 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hdfs/Put.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/hdfs/Put.java
@@ -41,7 +41,7 @@ class Put {
     private String text;
     private String file;
     private String to;
-    private boolean overwrite = false;
+    private boolean overwrite;
     private int permission = 755;
     private Integer blocksize;
     private Integer buffersize;

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilter.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilter.java b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilter.java
index 5f6611f..79442db 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilter.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilter.java
@@ -49,7 +49,7 @@ public class GatewayDispatchFilter extends AbstractGatewayFilter {
 
   private final Object lock = new Object();
 
-  private String whitelist = null;
+  private String whitelist;
 
   private Dispatch dispatch;
 

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/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 64ca2f8..06c9967 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
@@ -17,10 +17,11 @@
  */
 package org.apache.knox.gateway.dispatch;
 
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.Field;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.util.Date;
 import java.util.Properties;
 
@@ -38,7 +39,6 @@ public class HadoopAuthCookieStore extends BasicCookieStore {
 
   private GatewayConfig gatewayConfig;
 
-
   HadoopAuthCookieStore(GatewayConfig config) {
     this.gatewayConfig = config;
   }
@@ -55,7 +55,6 @@ public class HadoopAuthCookieStore extends BasicCookieStore {
     }
   }
 
-
   private static boolean isKnoxCookie(GatewayConfig config, Cookie cookie) {
     boolean result = false;
 
@@ -75,7 +74,7 @@ public class HadoopAuthCookieStore extends BasicCookieStore {
             String krb5Config = config.getKerberosLoginConfig();
             if (krb5Config != null && !krb5Config.isEmpty()) {
               Properties p = new Properties();
-              try (InputStream in = new FileInputStream(krb5Config)){
+              try (InputStream in = Files.newInputStream(Paths.get(krb5Config))){
                 p.load(in);
                 String configuredPrincipal = p.getProperty("principal");
                 // Strip off enclosing quotes, if present

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/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 94dcc8d..a5255a9 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
@@ -22,8 +22,8 @@ import java.util.HashMap;
 import java.util.StringTokenizer;
 
 public class SimplePrincipalMapper implements PrincipalMapper {
-  public HashMap<String, String[]> principalMappings = null;
-  public HashMap<String, String[]> groupMappings = null;
+  public HashMap<String, String[]> principalMappings;
+  public HashMap<String, String[]> groupMappings;
 
   public SimplePrincipalMapper() {
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/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 ff4b851..d69b678 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
@@ -25,11 +25,11 @@ import org.apache.knox.gateway.services.security.MasterService;
 
 import javax.crypto.spec.SecretKeySpec;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
 import java.security.Key;
 import java.security.KeyStore;
 import java.security.KeyStoreException;
@@ -49,7 +49,7 @@ public class BaseKeystoreService {
       throws CertificateException, IOException, KeyStoreException, NoSuchAlgorithmException {
        final KeyStore  keyStore = KeyStore.getInstance(storeType);
        if ( keyStoreFile.exists() ) {
-           try (FileInputStream input = new FileInputStream( keyStoreFile )) {
+           try (InputStream input = Files.newInputStream(keyStoreFile.toPath())) {
                keyStore.load( input, masterPassword );
            }
        } else {
@@ -59,7 +59,7 @@ public class BaseKeystoreService {
        return keyStore;
       }
 
-  private static FileOutputStream createKeyStoreFile( String fileName ) throws IOException {
+  private static OutputStream createKeyStoreFile(String fileName ) throws IOException {
     File file = new File( fileName );
     if( file.exists() ) {
       if( file.isDirectory() ) {
@@ -75,11 +75,11 @@ public class BaseKeystoreService {
         }
       }
     }
-    return new FileOutputStream( file );
+    return Files.newOutputStream( file.toPath() );
   }
 
   protected void createKeystore(String filename, String keystoreType) throws KeystoreServiceException {
-    try (FileOutputStream out = createKeyStoreFile( filename )) {
+    try (OutputStream out = createKeyStoreFile( filename )) {
       KeyStore ks = KeyStore.getInstance(keystoreType);
       ks.load( null, null );
       ks.store( out, masterService.getMasterSecret() );
@@ -91,7 +91,7 @@ public class BaseKeystoreService {
 
   protected boolean isKeystoreAvailable(final File keyStoreFile, String storeType) throws KeyStoreException, IOException {
     if ( keyStoreFile.exists() ) {
-      try (InputStream input = new FileInputStream(keyStoreFile)){
+      try (InputStream input = Files.newInputStream(keyStoreFile.toPath())){
         final KeyStore keyStore = KeyStore.getInstance(storeType);
         keyStore.load( input, masterService.getMasterSecret() );
         return true;
@@ -157,7 +157,7 @@ public class BaseKeystoreService {
   protected void writeCertificateToFile( Certificate cert, final File file ) throws CertificateEncodingException, IOException {
     byte[] bytes = cert.getEncoded();
     Base64 encoder = new Base64( 76, "\n".getBytes( StandardCharsets.US_ASCII ) );
-    try( FileOutputStream out = new FileOutputStream( file ) ) {
+    try( OutputStream out = Files.newOutputStream( file.toPath() ) ) {
       out.write( "-----BEGIN CERTIFICATE-----\n".getBytes( StandardCharsets.US_ASCII ) );
       out.write( encoder.encodeToString( bytes ).getBytes( StandardCharsets.US_ASCII ) );
       out.write( "-----END CERTIFICATE-----\n".getBytes( StandardCharsets.US_ASCII ) );
@@ -167,7 +167,7 @@ public class BaseKeystoreService {
   protected void writeKeystoreToFile(final KeyStore keyStore, final File file)
       throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException {
      // TODO: backup the keystore on disk before attempting a write and restore on failure
-     try( FileOutputStream out = new FileOutputStream(file) ) {
+     try( OutputStream out = Files.newOutputStream(file.toPath()) ) {
          keyStore.store( out, masterService.getMasterSecret() );
      }
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/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 961e7da..023583f 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
@@ -39,7 +39,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 char[] master;
   protected String serviceName;
   private ConfigurableEncryptor encryptor = new ConfigurableEncryptor(MASTER_PASSPHRASE);
 

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/X509CertificateUtil.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/X509CertificateUtil.java b/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/X509CertificateUtil.java
index 551fb5c..8e0a370 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/X509CertificateUtil.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/services/security/impl/X509CertificateUtil.java
@@ -18,14 +18,15 @@
 package org.apache.knox.gateway.services.security.impl;
 
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.math.BigInteger;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
 import java.security.KeyPair;
 import java.security.KeyStore;
 import java.security.KeyStoreException;
@@ -276,7 +277,7 @@ public class X509CertificateUtil {
        throws CertificateEncodingException, IOException {
     byte[] bytes = cert.getEncoded();
     Base64 encoder = new Base64( 76, "\n".getBytes( StandardCharsets.US_ASCII ) );
-    try( FileOutputStream out = new FileOutputStream( file ) ) {
+    try(OutputStream out = Files.newOutputStream(file.toPath()) ) {
       out.write( "-----BEGIN CERTIFICATE-----\n".getBytes( StandardCharsets.US_ASCII ) );
       out.write( encoder.encodeToString( bytes ).getBytes( StandardCharsets.US_ASCII ) );
       out.write( "-----END CERTIFICATE-----\n".getBytes( StandardCharsets.US_ASCII ) );
@@ -291,7 +292,7 @@ public class X509CertificateUtil {
     ks.load(null, password);
     ks.setCertificateEntry("gateway-identity", cert);
     /* Coverity Scan CID 1361992 */
-    try (FileOutputStream fos = new FileOutputStream(file)) {
+    try (OutputStream fos = Files.newOutputStream(file.toPath())) {
       ks.store(fos, password);
     }
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-spi/src/main/java/org/apache/knox/gateway/topology/Service.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/topology/Service.java b/gateway-spi/src/main/java/org/apache/knox/gateway/topology/Service.java
index 6b0c5de..d65704c 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/topology/Service.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/topology/Service.java
@@ -34,7 +34,7 @@ public class Service {
   private Version version;
   private Map<String, String> params = new LinkedHashMap<>();
   private List<String> urls;
-  private CustomDispatch dispatch = null;
+  private CustomDispatch dispatch;
 
   public String getRole() {
     return role;

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-spi/src/main/java/org/apache/knox/gateway/topology/Topology.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/knox/gateway/topology/Topology.java b/gateway-spi/src/main/java/org/apache/knox/gateway/topology/Topology.java
index c84673f..10f891e 100644
--- a/gateway-spi/src/main/java/org/apache/knox/gateway/topology/Topology.java
+++ b/gateway-spi/src/main/java/org/apache/knox/gateway/topology/Topology.java
@@ -32,7 +32,7 @@ public class Topology {
 
   private URI uri;
   private String name;
-  private String defaultServicePath = null;
+  private String defaultServicePath;
   private long timestamp;
   private boolean isGenerated;
   public List<Provider> providerList = new ArrayList<>();
@@ -41,7 +41,7 @@ public class Topology {
   private MultiKeyMap serviceMap;
   private List<Application> applications = new ArrayList<>();
   private Map<String,Application> applicationMap = new HashMap<>();
-  private CustomDispatch dispatch = null;
+  private CustomDispatch dispatch;
 
   public Topology() {
     serviceMap = MultiKeyMap.decorate(new HashedMap());

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-spi/src/test/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilterTest.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/test/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilterTest.java b/gateway-spi/src/test/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilterTest.java
index 6340182..8fc5183 100644
--- a/gateway-spi/src/test/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilterTest.java
+++ b/gateway-spi/src/test/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilterTest.java
@@ -270,7 +270,7 @@ public class GatewayDispatchFilterTest {
   }
 
   private static class TestHttpServletResponse extends MockHttpServletResponse {
-    int status = 0;
+    int status;
 
     @Override
     public void sendError(int i) throws IOException {

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-spi/src/test/java/org/apache/knox/gateway/services/security/impl/CMFMasterServiceTest.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/test/java/org/apache/knox/gateway/services/security/impl/CMFMasterServiceTest.java b/gateway-spi/src/test/java/org/apache/knox/gateway/services/security/impl/CMFMasterServiceTest.java
index 82170ed..8c329f2 100644
--- a/gateway-spi/src/test/java/org/apache/knox/gateway/services/security/impl/CMFMasterServiceTest.java
+++ b/gateway-spi/src/test/java/org/apache/knox/gateway/services/security/impl/CMFMasterServiceTest.java
@@ -35,7 +35,7 @@ import static org.junit.Assert.fail;
 */
 @Category( { UnitTests.class, FastTests.class } )
 public class CMFMasterServiceTest {
-  TestCMFMasterService ms = null;
+  TestCMFMasterService ms;
 
   @Before
   public void setup() {

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/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 1fb183a..ed89a2f 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
@@ -47,20 +47,20 @@ public class GatewayTestConfig extends Configuration implements GatewayConfig {
   private String gatewayHomeDir = "gateway-home";
   private String hadoopConfDir = "hadoop";
   private String gatewayHost = "localhost";
-  private int gatewayPort = 0;
+  private int gatewayPort;
   private String gatewayPath = "gateway";
-  private boolean hadoopKerberosSecured = false;
+  private boolean hadoopKerberosSecured;
   private String kerberosConfig = "/etc/knox/conf/krb5.conf";
-  private boolean kerberosDebugEnabled = false;
+  private boolean kerberosDebugEnabled;
   private String kerberosLoginConfig = "/etc/knox/conf/krb5JAASLogin.conf";
-  private String frontendUrl = null;
+  private String frontendUrl;
   private boolean xForwardedEnabled = true;
-  private String gatewayApplicationsDir = null;
+  private String gatewayApplicationsDir;
   private String gatewayServicesDir;
   private String defaultTopologyName = "default";
-  private List<String> includedSSLCiphers = null;
-  private List<String> excludedSSLCiphers = null;
-  private boolean sslEnabled = false;
+  private List<String> includedSSLCiphers;
+  private List<String> excludedSSLCiphers;
+  private boolean sslEnabled;
   private String truststoreType = "jks";
   private String keystoreType = "jks";
   private boolean isTopologyPortMappingEnabled = true;

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/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 03bbdad..ce5f846 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
@@ -21,9 +21,9 @@ import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
 
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.net.InetAddress;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -31,6 +31,7 @@ import java.net.URL;
 import java.net.UnknownHostException;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.FileSystems;
+import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.HashMap;
 import java.util.Map;
@@ -145,9 +146,9 @@ public class GatewayTestDriver {
     deployDir.mkdirs();
 
     File descriptor = new File( topoDir, cluster + ".xml" );
-    FileOutputStream stream = new FileOutputStream( descriptor );
-    topology.toStream( stream );
-    stream.close();
+    try(OutputStream stream = Files.newOutputStream(descriptor.toPath())) {
+        topology.toStream( stream );
+    }
 
     this.srvcs = new DefaultGatewayServices();
     Map<String,String> options = new HashMap<>();

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/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 fc1246a..152e057 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
@@ -54,18 +54,18 @@ public class MockRequestMatcher {
 
   private String from;
   private MockResponseProvider response;
-  private Set<String> methods = null;
-  private String pathInfo = null;
-  private String requestURL = null;
-  Map<String,Matcher> headers = null;
-  Set<Cookie> cookies = null;
-  private Map<String,Object> attributes = null;
-  private Map<String,String> queryParams = null;
-  private String contentType = null;
-  private String characterEncoding = null;
-  private Integer contentLength = null;
-  private byte[] entity = null;
-  private Map<String,String[]> formParams = null;
+  private Set<String> methods;
+  private String pathInfo;
+  private String requestURL;
+  Map<String,Matcher> headers;
+  Set<Cookie> cookies;
+  private Map<String,Object> attributes;
+  private Map<String,String> queryParams;
+  private String contentType;
+  private String characterEncoding;
+  private Integer contentLength;
+  private byte[] entity;
+  private Map<String,String[]> formParams;
 
   public MockRequestMatcher( MockResponseProvider response ) {
     this.response = response;

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockResponseProvider.java
----------------------------------------------------------------------
diff --git a/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockResponseProvider.java b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockResponseProvider.java
index 9dabded..1d5831a 100644
--- a/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockResponseProvider.java
+++ b/gateway-test-utils/src/main/java/org/apache/knox/test/mock/MockResponseProvider.java
@@ -33,16 +33,16 @@ import java.util.Set;
 
 public class MockResponseProvider {
 
-  Integer errorCode = null;
-  String errorMsg = null;
-  Integer statusCode = null;
-  String redirectUrl = null;
-  Map<String,String> headers = null;
-  Set<Cookie> cookies = null;
-  byte[] entity = null;
-  String contentType = null;
-  String characterEncoding = null;
-  Integer contentLength = null;
+  Integer errorCode;
+  String errorMsg;
+  Integer statusCode;
+  String redirectUrl;
+  Map<String,String> headers;
+  Set<Cookie> cookies;
+  byte[] entity;
+  String contentType;
+  String characterEncoding;
+  Integer contentLength;
 
   public MockResponseProvider status( int statusCode ) {
     this.statusCode = statusCode;

http://git-wip-us.apache.org/repos/asf/knox/blob/6a35473a/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/api/AuditServiceFactory.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/api/AuditServiceFactory.java b/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/api/AuditServiceFactory.java
index 8f4d0a1..77e8f7b 100644
--- a/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/api/AuditServiceFactory.java
+++ b/gateway-util-common/src/main/java/org/apache/knox/gateway/audit/api/AuditServiceFactory.java
@@ -22,7 +22,7 @@ import org.apache.knox.gateway.audit.log4j.audit.Log4jAuditService;
 public abstract class AuditServiceFactory {
 
   // The global audit service instance.
-  private static AuditService auditService = null;
+  private static AuditService auditService;
 
   // To prevent instantiation.
   private AuditServiceFactory() {


Mime
View raw message