Skip to content

Commit

Permalink
Add missing null-check to fulfill equals contract
Browse files Browse the repository at this point in the history
  • Loading branch information
zlosch authored and Sascha Scholz committed Sep 11, 2015
1 parent abc78c3 commit 64ea331
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public Key<?> getKey() {
}

@Override public boolean equals(Object obj) {
if (!(obj.getClass().equals(NodeId.class))) {
if (obj == null || !(obj.getClass().equals(NodeId.class))) {
return false;
}
NodeId other = (NodeId) obj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ public RealMapBinderProviderWithDependencies(Object equality) {

@Override
public boolean equals(Object obj) {
return this.getClass() == obj.getClass() &&
return obj != null && this.getClass() == obj.getClass() &&
equality.equals(((RealMapBinderProviderWithDependencies<?>)obj).equality);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ public RealOptionalBinderProviderWithDependencies(Object equality) {
}

@Override public boolean equals(Object obj) {
return this.getClass() == obj.getClass()
return obj != null && this.getClass() == obj.getClass()
&& equality.equals(((RealOptionalBinderProviderWithDependencies<?>) obj).equality);
}

Expand Down

0 comments on commit 64ea331

Please sign in to comment.