[jcifs] SmbFile.equals() always returning false

Rob Wygand rob at filefish.com
Tue Dec 11 11:21:52 EST 2001


Mike,

It was equals that was failing because hashcodes were always different. 
This fix made equals do the right thing (I've tested it fairly 
thouroughly). I'll let you know if anything else pops up related to this.

rjw

Allen, Michael B (RSCH) wrote:

>>-----Original Message-----
>>From:	Rob Wygand [SMTP:rob at wygand.com]
>>
>>
>>For the record, I fixed this by added a hashCode() function to 
>>UniAddress that explicity called hashCode on the address object.
>>
>>That is, I added:
>>
>>public int hashCode () {
>>   return addr.hashCode();
>>}
>>
>>
> 	I have to look at the code. I think you're assesment and fix is perfectly correct though.
> 	The hashcode for an address should be the integer representation of it's IP address. I
> 	think the above will do just that. This makes me wonder about some other methods
> 	though (e.g. equals).
> 
> 	Mike
> 
> 
>>Without that, the VM will default to the UniAddress's hashCode, which 
>>won't return the right thing.
>>
>>rjw
>>
>>Rob Wygand wrote:
>>
>>
>>>Mike,
>>>
>>>In 0.6b3, SmbFile.equals() is always returning 0. I've tracked this down 
>>>to SmbFile.hashCode(). Basically, SmbFile().hashCode() starts by calling 
>>>address.hashCode(). This value is coming back different every time, 
>>>which I assume is because there is no UniAddress.hashCode() and it's 
>>>using the default on in Object.
>>>
>>>The fix would be to implement UniAddress.hashCode(), I guess.
>>>
>>>Thoughts on a quick fix?
>>>rjw
>>>
>>>
>>
>>






More information about the jcifs mailing list