Skip to content

Commit

Permalink
HHH-7509 NPE regression in second level cache
Browse files Browse the repository at this point in the history
  • Loading branch information
stliu committed Aug 9, 2012
1 parent 8e73bb0 commit fae0d3f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Expand Up @@ -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 );
}
Expand Down
Expand Up @@ -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 );
}
Expand Down

0 comments on commit fae0d3f

Please sign in to comment.