[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[IDV #IOT-739511]: Please correct the ucar.unidata.data.DataSourceImpl.equals() code



> Hi...
> 
> the "equals()" method in DataSourceImpl is vulnerable to having a
> "null" value of the parameter.  While all other classes which I
> checked (not all of them, mind you) do handle this correctly
> (according to the "rule" in the Object.equals() method), this one does
> not.
> 
Tom,
    so I change the first line of this equals() api to:

 if ( o==null || !(getClass().equals(o.getClass()))) {
            return false;
     }

I believe this can avoid the NPE. 


Yuan
> Please make the change to test for null and return false.
> 
> We have some users who are trying to use this from Jython, and because the 
> test:
> 
> if (ret == None)
> 
> actually calls the equals() method (or the __eq__() method), this
> always creates an NPE.
> 
> (I am aware that saying " if (ret is None) " does not cause this -- we
> need to educate people separately...DataSourceImpl still should handle
> the 'null' case.)
> 
> Thanks.
> 
> tom
> 
> --
> Tom Whittaker
> University of Wisconsin-Madison
> Space Science & Engineering Center (SSEC)
> Cooperative Institute for Meteorological Satellite Studies (CIMSS)
> 1225 W. Dayton Street
> Madison, WI  53706  USA
> ph: +1 608 262 2759
> 
> 


Ticket Details
===================
Ticket ID: IOT-739511
Department: Support IDV
Priority: Normal
Status: Closed