Permalink
Browse files

HHH-7509 NPE regression in second level cache

  • Loading branch information...
stliu committed Aug 9, 2012
1 parent 8e73bb0 commit fae0d3f49877a5a11a7ac5cef25bb91235906fab
@@ -87,15 +87,18 @@ public String getTenantId() {
@Override
public boolean equals(Object other) {
+ if ( other == null ) {
+ return false;
+ }
if ( this == other ) {
return true;
}
- if ( !(other instanceof CacheKey) || hashCode != other.hashCode()) {
+ if ( hashCode != other.hashCode() || !( other instanceof CacheKey ) ) {
//hashCode is part of this check since it is pre-calculated and hash must match for equals to be true
return false;
}
CacheKey that = (CacheKey) other;
- return entityOrRoleName.equals( that.entityOrRoleName ) &&
+ return EqualsHelper.equals( entityOrRoleName, that.entityOrRoleName ) &&
type.isEqual( key, that.key ) &&
EqualsHelper.equals( tenantId, that.tenantId );
}
@@ -137,17 +137,20 @@ public int hashCode() {
@Override
public boolean equals(Object o) {
+ if ( o == null ) {
+ return false;
+ }
if ( this == o ) {
return true;
}
-
- if ( !(o instanceof NaturalIdCacheKey) || hashCode != o.hashCode() ) {
+
+ if ( hashCode != o.hashCode() || !( o instanceof NaturalIdCacheKey ) ) {
//hashCode is part of this check since it is pre-calculated and hash must match for equals to be true
return false;
}
final NaturalIdCacheKey other = (NaturalIdCacheKey) o;
- return entityName.equals( other.entityName )
+ return EqualsHelper.equals( entityName, other.entityName )
&& EqualsHelper.equals( tenantId, other.tenantId )
&& Arrays.deepEquals( this.naturalIdValues, other.naturalIdValues );
}

0 comments on commit fae0d3f

Please sign in to comment.