Fixing squid:S2259 - Null pointers should not be dereferenced

This commit is contained in:
Kirill Vlasov 2015-12-22 11:31:22 +05:00 committed by Vlad Mihalcea
parent b3e260b234
commit 2d8e9d66e2
6 changed files with 6 additions and 6 deletions

View File

@ -76,7 +76,7 @@ public class EntityUniqueKey implements Serializable {
@Override
public boolean equals(Object other) {
EntityUniqueKey that = (EntityUniqueKey) other;
return that.entityName.equals( entityName )
return that != null && that.entityName.equals( entityName )
&& that.uniqueKeyName.equals( uniqueKeyName )
&& keyType.isEqual( that.key, key );
}

View File

@ -216,7 +216,7 @@ public final class IdentityMap<K,V> implements Map<K,V> {
@SuppressWarnings( {"EqualsWhichDoesntCheckParameterClass"})
@Override
public boolean equals(Object other) {
return key == ( (IdentityKey) other ).key;
return other != null && key == ( (IdentityKey) other ).key;
}
@Override

View File

@ -817,7 +817,7 @@ public class JoinWalker {
@Override
public boolean equals(Object other) {
AssociationKey that = (AssociationKey) other;
return that.table.equals( table ) && Arrays.equals( columns, that.columns );
return that != null && that.table.equals( table ) && Arrays.equals( columns, that.columns );
}
@Override

View File

@ -869,7 +869,7 @@ public class Table implements RelationalModel, Serializable, Exportable {
public boolean equals(Object other) {
ForeignKeyKey fkk = (ForeignKeyKey) other;
return fkk.columns.equals( columns ) && fkk.referencedColumns.equals( referencedColumns );
return fkk != null && fkk.columns.equals( columns ) && fkk.referencedColumns.equals( referencedColumns );
}
@Override

View File

@ -118,7 +118,7 @@ public class ConcurrentServiceBinding<K,V> {
//so just let it happen as a form of assertion.
final Entry<K,V> other = (Entry<K,V>)obj;
//Reference equality on the key only!
return other.key == this.key;
return other != null && other.key == this.key;
}
@Override

View File

@ -130,7 +130,7 @@ public class DynamicMapEntityTuplizer extends AbstractEntityTuplizer {
@Override
public boolean equals(Object obj) {
return getClass().equals( obj.getClass() );
return obj != null && getClass().equals( obj.getClass() );
}
@Override