Bug 47969 - Problematic equals methods
Summary: Problematic equals methods
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.5-FINAL
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2009-10-09 00:46 UTC by David Horwitz
Modified: 2009-10-13 16:39 UTC (History)
0 users

Fix 4 problematic equals statements (2.95 KB, patch)
2009-10-09 00:46 UTC, David Horwitz
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Horwitz 2009-10-09 00:46:30 UTC
Created attachment 24367 [details]
Fix 4 problematic equals statements

There are 4 equals methods in the org.apache.ss package
that show the same broken pattern. They assume that they are being passed
non-null values of the same Class. The attached patch fixes these.

The classes affected are:
Comment 1 Josh Micich 2009-10-13 16:39:04 UTC
I guess these 'problems' were also found by an automated code checker.  Actually, all four equals() methods were optimised for performance, knowing that the instanceof check is not needed.  Note that none of the classes is public.  I am pretty sure it is impossible to get a CCE or NPE from any of these methods, no matter how you exercise POI.

Nonetheless, there's value in making it clear that code is not broken, so I have added "assert obj instanceof <MyKeyClass>" statements to three of the equals method, and deleted one which was unused (svn r824972 ). This change should have negligible performance impact and should also suppress the code checker warning.