Skip to content

Commit

Permalink
Add type tests to equals() before casting. (AcademySoftwareFoundation…
Browse files Browse the repository at this point in the history
  • Loading branch information
bcipriano authored Jan 19, 2021
1 parent fa9b644 commit a40e641
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 3 additions & 4 deletions cuebot/src/main/java/com/imageworks/spcue/SortableShow.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,11 @@ public boolean equals(Object other) {
if (other == null) {
return false;
}
try {
SortableShow that = (SortableShow) other;
return that.getShowId().equals(this.getShowId());
} catch (ClassCastException e) {
if (this.getClass() != other.getClass()) {
return false;
}
SortableShow that = (SortableShow) other;
return that.getShowId().equals(this.getShowId());
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,11 @@ public boolean equals(Object other) {
if (other == null) {
return false;
}
try {
DispatchBookHost that = (DispatchBookHost) other;
return that.host.name.equals(host.name);
} catch (ClassCastException e) {
if (this.getClass() != other.getClass()) {
return false;
}
DispatchBookHost that = (DispatchBookHost) other;
return that.host.name.equals(host.name);
};
}

0 comments on commit a40e641

Please sign in to comment.