[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


NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.