knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmc...@apache.org
Subject knox git commit: KNOX-792 - Fix FindBugs "performance" issues - Colm O hEigeartaigh via lmccay
Date Mon, 12 Dec 2016 20:44:52 GMT
Repository: knox
Updated Branches:
  refs/heads/master 33307d575 -> 3e3db7b4f


KNOX-792 - Fix FindBugs "performance" issues - Colm O hEigeartaigh via lmccay

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

Branch: refs/heads/master
Commit: 3e3db7b4ff62134479bb7f698dbe00152f6ed7ef
Parents: 33307d5
Author: Larry McCay <lmccay@hortonworks.com>
Authored: Mon Dec 12 15:44:40 2016 -0500
Committer: Larry McCay <lmccay@hortonworks.com>
Committed: Mon Dec 12 15:44:40 2016 -0500

----------------------------------------------------------------------
 .../filter/rewrite/impl/UrlRewriteRequest.java  |  2 --
 .../filter/rewrite/impl/UrlRewriteResponse.java |  2 --
 .../deploy/impl/ShiroDeploymentContributor.java |  2 +-
 .../topology/validation/TopologyValidator.java  |  7 ++++---
 .../apache/hadoop/gateway/trace/TraceUtil.java  |  2 +-
 .../service/admin/TopologiesResource.java       |  5 -----
 .../hadoop/test/mock/MockRequestMatcher.java    | 21 ++++++++++----------
 .../hadoop/test/mock/MockResponseProvider.java  |  5 +++--
 .../apache/hadoop/gateway/launcher/Command.java |  2 --
 9 files changed, 20 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/3e3db7b4/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteRequest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteRequest.java
b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteRequest.java
index 7ba91f4..9c7c66c 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteRequest.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteRequest.java
@@ -60,7 +60,6 @@ public class UrlRewriteRequest extends GatewayRequestWrapper implements
Resolver
   private String headersFilterName;
   private UrlRewriteFilterContentDescriptor headersFilterConfig;
   private String cookiesFilterName;
-  private UrlRewriteFilterContentDescriptor cookiesFilterConfig;
 
   /**
    * Constructs a request object wrapping the given request.
@@ -76,7 +75,6 @@ public class UrlRewriteRequest extends GatewayRequestWrapper implements
Resolver
     this.headersFilterName = config.getInitParameter( UrlRewriteServletFilter.REQUEST_HEADERS_FILTER_PARAM
);
     this.headersFilterConfig = getRewriteFilterConfig( headersFilterName, UrlRewriteServletFilter.HEADERS_MIME_TYPE
);
     this.cookiesFilterName = config.getInitParameter( UrlRewriteServletFilter.REQUEST_COOKIES_FILTER_PARAM
);
-    this.cookiesFilterConfig = getRewriteFilterConfig( cookiesFilterName, UrlRewriteServletFilter.COOKIES_MIME_TYPE
);
   }
 
   private Template getSourceUrl() {

http://git-wip-us.apache.org/repos/asf/knox/blob/3e3db7b4/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteResponse.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteResponse.java
b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteResponse.java
index 182efda..2933cfb 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteResponse.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteResponse.java
@@ -87,7 +87,6 @@ public class UrlRewriteResponse extends GatewayResponseWrapper implements
Params
   private String headersFilterName;
   private UrlRewriteFilterContentDescriptor headersFilterConfig;
   private String cookiesFilterName;
-  private UrlRewriteFilterContentDescriptor cookiesFilterConfig;
   private String xForwardedHostname;
   private String xForwardedPort;
   private String xForwardedScheme;
@@ -105,7 +104,6 @@ public class UrlRewriteResponse extends GatewayResponseWrapper implements
Params
     this.headersFilterName = config.getInitParameter( UrlRewriteServletFilter.RESPONSE_HEADERS_FILTER_PARAM
);
     this.headersFilterConfig = getRewriteFilterConfig( rewriter.getConfig(), headersFilterName,
UrlRewriteServletFilter.HEADERS_MIME_TYPE );
     this.cookiesFilterName = config.getInitParameter( UrlRewriteServletFilter.RESPONSE_COOKIES_FILTER_PARAM
);
-    this.cookiesFilterConfig = getRewriteFilterConfig( rewriter.getConfig(), cookiesFilterName,
UrlRewriteServletFilter.COOKIES_MIME_TYPE );
   }
 
   protected boolean ignoreHeader( String name ) {

http://git-wip-us.apache.org/repos/asf/knox/blob/3e3db7b4/gateway-provider-security-shiro/src/main/java/org/apache/hadoop/gateway/deploy/impl/ShiroDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-shiro/src/main/java/org/apache/hadoop/gateway/deploy/impl/ShiroDeploymentContributor.java
b/gateway-provider-security-shiro/src/main/java/org/apache/hadoop/gateway/deploy/impl/ShiroDeploymentContributor.java
index 8cabf6e..2b63be6 100644
--- a/gateway-provider-security-shiro/src/main/java/org/apache/hadoop/gateway/deploy/impl/ShiroDeploymentContributor.java
+++ b/gateway-provider-security-shiro/src/main/java/org/apache/hadoop/gateway/deploy/impl/ShiroDeploymentContributor.java
@@ -74,7 +74,7 @@ public class ShiroDeploymentContributor extends ProviderDeploymentContributorBas
     Map<String, String> params = provider.getParams();
     String sts = params.get( SESSION_TIMEOUT );
     if( sts != null && sts.trim().length() != 0 ) {
-      st = Integer.valueOf( sts.trim() );
+      st = Integer.parseInt( sts.trim() );
     }
     if( st <= 0 ) {
       // user default session timeout

http://git-wip-us.apache.org/repos/asf/knox/blob/3e3db7b4/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/validation/TopologyValidator.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/validation/TopologyValidator.java
b/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/validation/TopologyValidator.java
index 37d202f..a29758c 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/validation/TopologyValidator.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/validation/TopologyValidator.java
@@ -111,11 +111,12 @@ public class TopologyValidator {
   }
 
   public String getErrorString(){
-    String out = "";
+    StringBuilder out = new StringBuilder();
+    out.append("");
     for(String s : getTopologyErrors()){
-      out += s + "\n";
+      out.append(s + "\n");
     }
-    return out;
+    return out.toString();
   }
 
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/3e3db7b4/gateway-server/src/main/java/org/apache/hadoop/gateway/trace/TraceUtil.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/trace/TraceUtil.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/trace/TraceUtil.java
index 59e4064..91babad 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/trace/TraceUtil.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/trace/TraceUtil.java
@@ -62,7 +62,7 @@ public class TraceUtil {
   private static final void addParsedIntegerToSet( Set<Integer> set, String str ) {
     if( str != null && !str.trim().isEmpty() ) {
       try {
-        set.add( new Integer( str.trim() ) );
+        set.add( Integer.valueOf( str.trim() ) );
       } catch( NumberFormatException e ) {
         // Ignore it.
       }

http://git-wip-us.apache.org/repos/asf/knox/blob/3e3db7b4/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologiesResource.java
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologiesResource.java
b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologiesResource.java
index 706abb7..52198ee 100644
--- a/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologiesResource.java
+++ b/gateway-service-admin/src/main/java/org/apache/hadoop/gateway/service/admin/TopologiesResource.java
@@ -236,11 +236,6 @@ public class TopologiesResource {
     return baseURL;
   }
 
-//  Uses member request variable
-  private String buildXForwardBaseURL(){
-    return buildXForwardBaseURL(request);
-  }
-
   @XmlAccessorType(XmlAccessType.NONE)
   public static class SimpleTopology {
 

http://git-wip-us.apache.org/repos/asf/knox/blob/3e3db7b4/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockRequestMatcher.java
----------------------------------------------------------------------
diff --git a/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockRequestMatcher.java
b/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockRequestMatcher.java
index 378f02f..3b2b20b 100644
--- a/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockRequestMatcher.java
+++ b/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockRequestMatcher.java
@@ -36,6 +36,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 
 import static org.hamcrest.CoreMatchers.*;
@@ -214,11 +215,11 @@ public class MockRequestMatcher {
           request.getRequestURL().toString(), is( requestURL ) );
     }
     if( headers != null ) {
-      for( String name: headers.keySet() ) {
+      for( Entry<String, Matcher> entry : headers.entrySet() ) {
         assertThat(
             "Request " + request.getMethod() + " " + request.getRequestURL() +
-                " does not have the expected value for header " + name,
-            request.getHeader( name ),  headers.get(name) );
+                " does not have the expected value for header " + entry.getKey(),
+            request.getHeader( entry.getKey() ),  entry.getValue() );
       }
     }
     if( cookies != null ) {
@@ -266,23 +267,23 @@ public class MockRequestMatcher {
     if( queryParams != null ) {
       String queryString = request.getQueryString();
       List<NameValuePair> requestParams = parseQueryString( queryString == null ? ""
: queryString );
-      for( String name: queryParams.keySet() ) {
+      for( Entry<String, String> entry : queryParams.entrySet() ) {
         assertThat(
             "Request " + request.getMethod() + " " + request.getRequestURL() +
-                " query string " + queryString + " is missing parameter '" + name + "'",
-            requestParams, hasItem( new BasicNameValuePair(name, queryParams.get(name)))
);
+                " query string " + queryString + " is missing parameter '" + entry.getKey()
+ "'",
+            requestParams, hasItem( new BasicNameValuePair(entry.getKey(), entry.getValue()))
);
       }
     }
     if( formParams != null ) {
       String paramString = IOUtils.toString( request.getInputStream(), request.getCharacterEncoding()
);
       List<NameValuePair> requestParams = parseQueryString( paramString == null ? ""
: paramString );
-      for( String name: formParams.keySet() ) {
-        String[] expectedValues = formParams.get( name );
+      for( Entry<String, String[]> entry : formParams.entrySet() ) {
+        String[] expectedValues = entry.getValue();
         for( String expectedValue : expectedValues ) {
           assertThat(
               "Request " + request.getMethod() + " " + request.getRequestURL() +
-                  " form params " + paramString + " is missing a value " + expectedValue
+ " for parameter '" + name + "'",
-              requestParams, hasItem( new BasicNameValuePair(name, expectedValue ) ));
+                  " form params " + paramString + " is missing a value " + expectedValue
+ " for parameter '" + entry.getKey() + "'",
+              requestParams, hasItem( new BasicNameValuePair(entry.getKey(), expectedValue
) ));
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/3e3db7b4/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockResponseProvider.java
----------------------------------------------------------------------
diff --git a/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockResponseProvider.java
b/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockResponseProvider.java
index 3592d1a..82571ef 100644
--- a/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockResponseProvider.java
+++ b/gateway-test-utils/src/main/java/org/apache/hadoop/test/mock/MockResponseProvider.java
@@ -29,6 +29,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 
 public class MockResponseProvider {
@@ -129,8 +130,8 @@ public class MockResponseProvider {
       response.sendRedirect( redirectUrl );
     }
     if( headers != null ) {
-      for( String name: headers.keySet() ) {
-        response.addHeader( name, headers.get( name ) );
+      for( Entry<String, String> entry : headers.entrySet() ) {
+        response.addHeader( entry.getKey(), entry.getValue() );
       }
     }
     if( cookies != null ) {

http://git-wip-us.apache.org/repos/asf/knox/blob/3e3db7b4/gateway-util-launcher/src/main/java/org/apache/hadoop/gateway/launcher/Command.java
----------------------------------------------------------------------
diff --git a/gateway-util-launcher/src/main/java/org/apache/hadoop/gateway/launcher/Command.java
b/gateway-util-launcher/src/main/java/org/apache/hadoop/gateway/launcher/Command.java
index 10d3f8b..09c661e 100644
--- a/gateway-util-launcher/src/main/java/org/apache/hadoop/gateway/launcher/Command.java
+++ b/gateway-util-launcher/src/main/java/org/apache/hadoop/gateway/launcher/Command.java
@@ -44,7 +44,6 @@ class Command {
   private static int ENV_PREFIX_LENGTH = ENV_PREFIX.length();
 
   File base;
-  Properties config;
   String mainClass;
   String mainMethod = "main";
   String[] mainArgs;
@@ -57,7 +56,6 @@ class Command {
 
   Command( File base, Properties config, String[] args ) throws MalformedURLException {
     this.base = base;
-    this.config = config;
     this.mainArgs = args ;
     consumeConfig( config );
   }


Mime
View raw message