Reimplement some hashCodes according to the currently recommended pattern.

These hashCode implementations seemed suspicious (field hashCodes XORed together with 31).
Included caseSensitive in AntPathRequestMatcher.hashCode() to be consistent with equals().
This commit is contained in:
Bagyoni Attila 2019-02-15 20:10:39 +01:00 committed by Josh Cummings
parent f44eb0b7be
commit 878d262a26
5 changed files with 16 additions and 20 deletions

View File

@ -152,11 +152,9 @@ public class ObjectIdentityImpl implements ObjectIdentity {
*/
@Override
public int hashCode() {
int code = 31;
code ^= this.type.hashCode();
code ^= this.identifier.hashCode();
return code;
int result = this.type.hashCode();
result = 31 * result + this.identifier.hashCode();
return result;
}
@Override

View File

@ -58,7 +58,9 @@ public final class JaasGrantedAuthority implements GrantedAuthority {
@Override
public int hashCode() {
return 31 ^ principal.hashCode() ^ role.hashCode();
int result = this.principal.hashCode();
result = 31 * result + this.role.hashCode();
return result;
}
@Override

View File

@ -45,14 +45,9 @@ public class RequestKey {
@Override
public int hashCode() {
int code = 31;
code ^= url.hashCode();
if (method != null) {
code ^= method.hashCode();
}
return code;
int result = this.url.hashCode();
result = 31 * result + (this.method != null ? this.method.hashCode() : 0);
return result;
}
@Override

View File

@ -70,7 +70,9 @@ public final class SwitchUserGrantedAuthority implements GrantedAuthority {
@Override
public int hashCode() {
return 31 ^ source.hashCode() ^ role.hashCode();
int result = this.role.hashCode();
result = 31 * result + this.source.hashCode();
return result;
}
@Override

View File

@ -220,11 +220,10 @@ public final class AntPathRequestMatcher
@Override
public int hashCode() {
int code = 31 ^ this.pattern.hashCode();
if (this.httpMethod != null) {
code ^= this.httpMethod.hashCode();
}
return code;
int result = this.pattern != null ? this.pattern.hashCode() : 0;
result = 31 * result + (this.httpMethod != null ? this.httpMethod.hashCode() : 0);
result = 31 * result + (this.caseSensitive ? 1231 : 1237);
return result;
}
@Override