Fix UriComponents.equals() method

Fix HierarchicalUriComponents and OpaqueUriComponents .equals() methods.

Issue: SPR-10313
This commit is contained in:
Phillip Webb
2013-02-19 13:19:42 -08:00
parent 7e2022b9a7
commit 5b7969e726
3 changed files with 45 additions and 36 deletions

View File

@@ -39,6 +39,7 @@ import org.springframework.util.StringUtils;
* Extension of {@link UriComponents} for hierarchical URIs.
*
* @author Arjen Poutsma
* @author Phillip Webb
* @since 3.1.3
* @see <a href="http://tools.ietf.org/html/rfc3986#section-1.2.3">Hierarchical URIs</a>
*/
@@ -430,28 +431,15 @@ final class HierarchicalUriComponents extends UriComponents {
return false;
}
HierarchicalUriComponents other = (HierarchicalUriComponents) obj;
if (ObjectUtils.nullSafeEquals(getScheme(), other.getScheme())) {
return false;
}
if (ObjectUtils.nullSafeEquals(getUserInfo(), other.getUserInfo())) {
return false;
}
if (ObjectUtils.nullSafeEquals(getHost(), other.getHost())) {
return false;
}
if (this.port != other.port) {
return false;
}
if (!this.path.equals(other.path)) {
return false;
}
if (!this.queryParams.equals(other.queryParams)) {
return false;
}
if (ObjectUtils.nullSafeEquals(getFragment(), other.getFragment())) {
return false;
}
return true;
boolean rtn = true;
rtn &= ObjectUtils.nullSafeEquals(getScheme(), other.getScheme());
rtn &= ObjectUtils.nullSafeEquals(getUserInfo(), other.getUserInfo());
rtn &= ObjectUtils.nullSafeEquals(getHost(), other.getHost());
rtn &= getPort() == other.getPort();
rtn &= this.path.equals(other.path);
rtn &= this.queryParams.equals(other.queryParams);
rtn &= ObjectUtils.nullSafeEquals(getFragment(), other.getFragment());
return rtn;
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ import org.springframework.util.ObjectUtils;
* Extension of {@link UriComponents} for opaque URIs.
*
* @author Arjen Poutsma
* @author Phillip Webb
* @since 3.2
* @see <a href="http://tools.ietf.org/html/rfc3986#section-1.2.3">Hierarchical vs Opaque URIs</a>
*/
@@ -145,18 +146,11 @@ final class OpaqueUriComponents extends UriComponents {
}
OpaqueUriComponents other = (OpaqueUriComponents) obj;
if (ObjectUtils.nullSafeEquals(getScheme(), other.getScheme())) {
return false;
}
if (ObjectUtils.nullSafeEquals(this.ssp, other.ssp)) {
return false;
}
if (ObjectUtils.nullSafeEquals(getFragment(), other.getFragment())) {
return false;
}
return true;
boolean rtn = true;
rtn &= ObjectUtils.nullSafeEquals(getScheme(), other.getScheme());
rtn &= ObjectUtils.nullSafeEquals(this.ssp, other.ssp);
rtn &= ObjectUtils.nullSafeEquals(getFragment(), other.getFragment());
return rtn;
}
@Override