Skip to content

Commit

Permalink
Merge pull request google#953 from zlosch/fix-equals
Browse files Browse the repository at this point in the history
Add missing null-check to fulfill equals contract
  • Loading branch information
sameb committed Dec 22, 2015
2 parents f4985ec + 64ea331 commit b18f23f
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 b18f23f

Please sign in to comment.