knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kris...@apache.org
Subject knox git commit: KNOX-1671 - Cleanup misc logic errors identified by Sonarqube
Date Wed, 12 Dec 2018 17:18:57 GMT
Repository: knox
Updated Branches:
  refs/heads/master fcb97c75d -> e7262162a


KNOX-1671 - Cleanup misc logic errors identified by Sonarqube

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


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

Branch: refs/heads/master
Commit: e7262162a6d4e3efdd1a666cc33b7e575aa746af
Parents: fcb97c7
Author: Kevin Risden <krisden@apache.org>
Authored: Wed Dec 12 11:28:40 2018 -0500
Committer: Kevin Risden <krisden@apache.org>
Committed: Wed Dec 12 11:28:44 2018 -0500

----------------------------------------------------------------------
 .../ambari/AmbariConfigurationMonitor.java          |  2 +-
 .../ambari/AmbariDynamicServiceURLCreator.java      |  6 +++---
 .../ha/provider/HaServletContextListener.java       | 10 ----------
 .../api/UrlRewriteServletContextListener.java       |  4 ----
 .../filter/rewrite/impl/UrlRewriteRequest.java      | 15 +++++----------
 .../federation/jwt/filter/AbstractJWTFilter.java    |  2 +-
 .../deploy/impl/ShiroDeploymentContributor.java     |  4 +---
 .../knox/gateway/filter/ResponseCookieFilter.java   |  5 ++---
 .../knox/gateway/config/impl/GatewayConfigImpl.java | 16 +++++-----------
 .../impl/GenericProviderDeploymentContributor.java  | 12 +++++-------
 .../java/org/apache/knox/gateway/util/KnoxCLI.java  |  5 -----
 .../knox/gateway/service/admin/VersionResource.java |  8 +-------
 .../java/org/apache/knox/gateway/util/JsonPath.java |  6 ++++++
 .../apache/knox/gateway/util/urltemplate/Query.java | 14 ++++++++++++++
 14 files changed, 44 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/e7262162/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariConfigurationMonitor.java
----------------------------------------------------------------------
diff --git a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariConfigurationMonitor.java
b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariConfigurationMonitor.java
index e533734..fc8cc96 100644
--- a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariConfigurationMonitor.java
+++ b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariConfigurationMonitor.java
@@ -519,7 +519,7 @@ class AmbariConfigurationMonitor implements ClusterConfigurationMonitor
{
                 }
 
                 try {
-                    Thread.sleep(interval * 1000);
+                    Thread.sleep(interval * 1000L);
                 } catch (InterruptedException e) {
                     // Ignore
                 }

http://git-wip-us.apache.org/repos/asf/knox/blob/e7262162/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreator.java
----------------------------------------------------------------------
diff --git a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreator.java
b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreator.java
index 1ad1830..d2199f7 100644
--- a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreator.java
+++ b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreator.java
@@ -156,10 +156,10 @@ class AmbariDynamicServiceURLCreator implements ServiceURLCreator {
                             }
                         }
                     }
-                }
 
-                log.determinedPropertyValue(configProperty.getName(), propertyValue);
-                placeholderValues.put(configProperty.getName(), propertyValue);
+                    log.determinedPropertyValue(configProperty.getName(), propertyValue);
+                    placeholderValues.put(configProperty.getName(), propertyValue);
+                }
             }
 
             // For patterns with a placeholder value for the hostname (e.g., multiple URL
scenarios)

http://git-wip-us.apache.org/repos/asf/knox/blob/e7262162/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/HaServletContextListener.java
----------------------------------------------------------------------
diff --git a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/HaServletContextListener.java
b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/HaServletContextListener.java
index 0533932..37424ae 100644
--- a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/HaServletContextListener.java
+++ b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/HaServletContextListener.java
@@ -27,7 +27,6 @@ import org.apache.knox.gateway.services.registry.ServiceRegistry;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
@@ -35,18 +34,13 @@ import java.net.URL;
 import java.util.List;
 
 public class HaServletContextListener implements ServletContextListener {
-
    public static final String PROVIDER_ATTRIBUTE_NAME = "haProvider";
-
    public static final String DESCRIPTOR_LOCATION_INIT_PARAM_NAME = "haDescriptorLocation";
-
    public static final String DESCRIPTOR_DEFAULT_FILE_NAME = "ha.xml";
-
    public static final String DESCRIPTOR_DEFAULT_LOCATION = "/WEB-INF/" + DESCRIPTOR_DEFAULT_FILE_NAME;
 
    private static final HaMessages LOG = MessagesFactory.get(HaMessages.class);
 
-
    @Override
    public void contextInitialized(ServletContextEvent event) {
       HaDescriptor descriptor;
@@ -96,9 +90,6 @@ public class HaServletContextListener implements ServletContextListener
{
       if (url == null) {
          url = new URL(param);
       }
-      if (url == null) {
-         throw new FileNotFoundException(param);
-      }
       return url;
    }
 
@@ -112,5 +103,4 @@ public class HaServletContextListener implements ServletContextListener
{
       }
       return descriptor;
    }
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/e7262162/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletContextListener.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletContextListener.java
b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletContextListener.java
index 631cecc..aa98ace 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletContextListener.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletContextListener.java
@@ -24,7 +24,6 @@ import javax.servlet.ServletContextListener;
 import org.apache.knox.gateway.filter.rewrite.i18n.UrlRewriteMessages;
 import org.apache.knox.gateway.i18n.messages.MessagesFactory;
 
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -86,9 +85,6 @@ public class UrlRewriteServletContextListener implements ServletContextListener
     if( url == null ) {
       url = new URL( param );
     }
-    if( url == null ) {
-      throw new FileNotFoundException( param );
-    }
     return url;
   }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/e7262162/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteRequest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteRequest.java
b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteRequest.java
index b92dfaf..1430f93 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteRequest.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteRequest.java
@@ -110,17 +110,12 @@ public class UrlRewriteRequest extends GatewayRequestWrapper implements
Resolver
 
   // Note: Source url was added to the request attributes by the GatewayFilter doFilter method.
   Template getTargetUrl() {
-    boolean rewriteRequestUrl = true;
     Template targetUrl;
-    if( rewriteRequestUrl ) {
-      targetUrl = (Template)getAttribute( AbstractGatewayFilter.TARGET_REQUEST_URL_ATTRIBUTE_NAME
);
-      if( targetUrl == null ) {
-        Template sourceUrl = getSourceUrl();
-        targetUrl = rewriter.rewrite( this, sourceUrl, UrlRewriter.Direction.IN, urlRuleName
);
-        setAttribute( AbstractGatewayFilter.TARGET_REQUEST_URL_ATTRIBUTE_NAME, targetUrl
);
-      }
-    } else {
-      targetUrl = (Template)getAttribute( AbstractGatewayFilter.SOURCE_REQUEST_URL_ATTRIBUTE_NAME
);
+    targetUrl = (Template)getAttribute( AbstractGatewayFilter.TARGET_REQUEST_URL_ATTRIBUTE_NAME
);
+    if( targetUrl == null ) {
+      Template sourceUrl = getSourceUrl();
+      targetUrl = rewriter.rewrite( this, sourceUrl, UrlRewriter.Direction.IN, urlRuleName
);
+      setAttribute( AbstractGatewayFilter.TARGET_REQUEST_URL_ATTRIBUTE_NAME, targetUrl );
     }
     return targetUrl;
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/e7262162/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/AbstractJWTFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/AbstractJWTFilter.java
b/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/AbstractJWTFilter.java
index 418e38e..1a1ea64 100644
--- a/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/AbstractJWTFilter.java
+++ b/gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/AbstractJWTFilter.java
@@ -140,7 +140,7 @@ public abstract class AbstractJWTFilter implements Filter {
     // the cookie validity - otherwise ensure that the current time is before
     // the designated expiration time
     Date expires = jwtToken.getExpiresDate();
-    return (expires == null || expires != null && new Date().before(expires));
+    return expires == null || new Date().before(expires);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/knox/blob/e7262162/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/deploy/impl/ShiroDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/deploy/impl/ShiroDeploymentContributor.java
b/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/deploy/impl/ShiroDeploymentContributor.java
index b379d36..345727f 100644
--- a/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/deploy/impl/ShiroDeploymentContributor.java
+++ b/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/deploy/impl/ShiroDeploymentContributor.java
@@ -87,9 +87,7 @@ public class ShiroDeploymentContributor extends ProviderDeploymentContributorBas
     String clusterName = context.getTopology().getName();
     ShiroConfig config = new ShiroConfig( provider, clusterName );
     String configStr = config.toString();
-    if( config != null ) {
-      context.getWebArchive().addAsWebInfResource( new StringAsset( configStr ), SHRIO_CONFIG_FILE_NAME
);
-    }
+    context.getWebArchive().addAsWebInfResource( new StringAsset( configStr ), SHRIO_CONFIG_FILE_NAME
);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/knox/blob/e7262162/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/filter/ResponseCookieFilter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/filter/ResponseCookieFilter.java
b/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/filter/ResponseCookieFilter.java
index 017f56b..5bf7181 100644
--- a/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/filter/ResponseCookieFilter.java
+++ b/gateway-provider-security-shiro/src/main/java/org/apache/knox/gateway/filter/ResponseCookieFilter.java
@@ -15,7 +15,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.knox.gateway.filter;
 
 import javax.servlet.FilterChain;
@@ -33,7 +32,7 @@ import java.util.List;
 public class ResponseCookieFilter extends AbstractGatewayFilter {
   public static final String RESTRICTED_COOKIES = "restrictedCookies";
 
-  protected static List<String> restrictedCookies = new ArrayList<>();
+  private List<String> restrictedCookies = new ArrayList<>();
 
   @Override
   public void init(FilterConfig filterConfig) throws ServletException {
@@ -51,7 +50,7 @@ public class ResponseCookieFilter extends AbstractGatewayFilter {
   }
 
   // inner class wraps response to prevent adding of not allowed headers
-  private static class ResponseWrapper extends HttpServletResponseWrapper {
+  private class ResponseWrapper extends HttpServletResponseWrapper {
     ResponseWrapper( HttpServletResponse response ) {
       super( response );
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/e7262162/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
b/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
index e86d547..6273015 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
@@ -89,7 +89,7 @@ public class GatewayConfigImpl extends Configuration implements GatewayConfig
{
 
   private static final String DEFAULT_APPLICATIONS_DIR = "applications";
 
-  public static final String[] GATEWAY_CONFIG_FILENAMES = {
+  private static final String[] GATEWAY_CONFIG_FILENAMES = {
       GATEWAY_CONFIG_DIR_PREFIX + "/" + GATEWAY_CONFIG_FILE_PREFIX + "-default.xml",
       GATEWAY_CONFIG_DIR_PREFIX + "/" + GATEWAY_CONFIG_FILE_PREFIX + "-site.xml"
   };
@@ -228,7 +228,7 @@ public class GatewayConfigImpl extends Configuration implements GatewayConfig
{
   static final String DISPATCH_HOST_WHITELIST          = GATEWAY_CONFIG_FILE_PREFIX + ".dispatch.whitelist";
   static final String DISPATCH_HOST_WHITELIST_SERVICES = DISPATCH_HOST_WHITELIST + ".services";
 
-  private static List<String> DEFAULT_GLOBAL_RULES_SERVICES;
+  private List<String> DEFAULT_GLOBAL_RULES_SERVICES;
 
   public GatewayConfigImpl() {
     init();
@@ -310,15 +310,9 @@ public class GatewayConfigImpl extends Configuration implements GatewayConfig
{
   }
 
   private void setDefaultGlobalRulesServices() {
-    DEFAULT_GLOBAL_RULES_SERVICES = new ArrayList<>();
-    DEFAULT_GLOBAL_RULES_SERVICES.add("NAMENODE");
-    DEFAULT_GLOBAL_RULES_SERVICES.add("JOBTRACKER");
-    DEFAULT_GLOBAL_RULES_SERVICES.add("WEBHDFS");
-    DEFAULT_GLOBAL_RULES_SERVICES.add("WEBHCAT");
-    DEFAULT_GLOBAL_RULES_SERVICES.add("OOZIE");
-    DEFAULT_GLOBAL_RULES_SERVICES.add("WEBHBASE");
-    DEFAULT_GLOBAL_RULES_SERVICES.add("HIVE");
-    DEFAULT_GLOBAL_RULES_SERVICES.add("RESOURCEMANAGER");
+    DEFAULT_GLOBAL_RULES_SERVICES = Arrays.asList(
+        "NAMENODE", "JOBTRACKER", "WEBHDFS", "WEBHCAT",
+        "OOZIE", "WEBHBASE", "HIVE", "RESOURCEMANAGER");
   }
 
   private void initGatewayHomeDir( URL lastFileUrl ) {

http://git-wip-us.apache.org/repos/asf/knox/blob/e7262162/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/GenericProviderDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/GenericProviderDeploymentContributor.java
b/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/GenericProviderDeploymentContributor.java
index 9b133c9..3f419a9 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/GenericProviderDeploymentContributor.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/GenericProviderDeploymentContributor.java
@@ -52,13 +52,11 @@ public class GenericProviderDeploymentContributor extends
       ResourceDescriptor resource,
       List<FilterParamDescriptor> params ) {
     String filterClassName = getFilterClassName( provider.getParams() );
-    if( filterClassName != null ) {
-      FilterDescriptor filter = resource.addFilter();
-      filter.name( getName() );
-      filter.role( provider.getRole() );
-      filter.impl( filterClassName );
-      filter.params( getFilterInitParams( filter, provider.getParams(), params ) );
-    }
+    FilterDescriptor filter = resource.addFilter();
+    filter.name( getName() );
+    filter.role( provider.getRole() );
+    filter.impl( filterClassName );
+    filter.params( getFilterInitParams( filter, provider.getParams(), params ) );
   }
 
   private String getFilterClassName( Map<String,String> params ) {

http://git-wip-us.apache.org/repos/asf/knox/blob/e7262162/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 135c1eb..300edc1 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
@@ -850,11 +850,6 @@ public class KnoxCLI extends Configured implements Tool {
                "This command requires write permissions on the master secret file: " +
                    file.getAbsolutePath() );
            valid = false;
-         } else if( !file.canWrite() ) {
-           out.println(
-               "This command requires write permissions on the master secret file: " +
-                   file.getAbsolutePath() );
-           valid = false;
          } else {
            valid = file.delete();
            if( !valid ) {

http://git-wip-us.apache.org/repos/asf/knox/blob/e7262162/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/VersionResource.java
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/VersionResource.java
b/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/VersionResource.java
index 30e35ff..8227ef4 100644
--- a/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/VersionResource.java
+++ b/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/VersionResource.java
@@ -32,8 +32,6 @@ import org.apache.knox.gateway.services.ServerInfoService;
 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
 import static javax.ws.rs.core.MediaType.APPLICATION_XML;
 import static javax.ws.rs.core.Response.ok;
-import static javax.ws.rs.core.Response.status;
-import static javax.ws.rs.core.Response.Status.NOT_FOUND;
 
 @Path( "/api/v1" )
 public class VersionResource {
@@ -45,11 +43,7 @@ public class VersionResource {
   @Path( "version" )
   public Response getVersion() {
     ServerVersion version = getServerVersion();
-    if (version != null) {
-        return ok(version).build();
-    } else {
-        return status(NOT_FOUND).build();
-    }
+    return ok(version).build();
   }
 
   private ServerVersion getServerVersion() {

http://git-wip-us.apache.org/repos/asf/knox/blob/e7262162/gateway-util-common/src/main/java/org/apache/knox/gateway/util/JsonPath.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/main/java/org/apache/knox/gateway/util/JsonPath.java
b/gateway-util-common/src/main/java/org/apache/knox/gateway/util/JsonPath.java
index ab6054a..7ba65ed 100644
--- a/gateway-util-common/src/main/java/org/apache/knox/gateway/util/JsonPath.java
+++ b/gateway-util-common/src/main/java/org/apache/knox/gateway/util/JsonPath.java
@@ -133,6 +133,9 @@ public class JsonPath {
             if( expectChild ) {
               if( ".".equals( prevToken ) ) {
                 segment = new Segment( Segment.Type.GLOB );
+                if(list == null) {
+                  throw new IllegalArgumentException( expression );
+                }
                 list.add( segment );
                 expectChild = true;
                 foundChild = false;
@@ -191,6 +194,9 @@ public class JsonPath {
                 segment = new Segment( currToken );
               }
             }
+            if(list == null) {
+              throw new IllegalArgumentException( expression );
+            }
             list.add( segment );
             expectChild = false;
             foundChild = true;

http://git-wip-us.apache.org/repos/asf/knox/blob/e7262162/gateway-util-urltemplate/src/main/java/org/apache/knox/gateway/util/urltemplate/Query.java
----------------------------------------------------------------------
diff --git a/gateway-util-urltemplate/src/main/java/org/apache/knox/gateway/util/urltemplate/Query.java
b/gateway-util-urltemplate/src/main/java/org/apache/knox/gateway/util/urltemplate/Query.java
index e10b5bc..405e026 100644
--- a/gateway-util-urltemplate/src/main/java/org/apache/knox/gateway/util/urltemplate/Query.java
+++ b/gateway-util-urltemplate/src/main/java/org/apache/knox/gateway/util/urltemplate/Query.java
@@ -50,4 +50,18 @@ public class Query extends Segment {
     return matches;
   }
 
+  @Override
+  public boolean equals(Object obj) {
+    if( obj instanceof Query ) {
+      Query that = (Query)obj;
+      return super.equals(that) && that.getQueryName().equals(getQueryName());
+    }
+    return false;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = super.hashCode();
+    return 31 * result + getQueryName().hashCode();
+  }
 }


Mime
View raw message