Re: dirty socket growth problem

Peter Jones - JavaSoft East <[email protected]> Wed, 7 Dec 2005 14:46:11 -0500
Newsgroups gmane.comp.java.sun.rmi
Message-ID <20051207194611.GC17949@east>
>> My factory classes have the following equal and hashcode method (which as
>> far as I am aware is fine):
>>
>>     public int hashCode() { return 57; }
>>     public boolean equals(Object o) { return this.getClass() == o.getClass(); }

> Eeek... double equals.  That just checks if the pointers are the same..
> not the object pointed at.

which is always the same thing for java.lang.Class objects.

> Also you may consider changing this.getClass() to
> this.getClass().getName() incase the two factories came from
> different classloaders.

If that worked, it could introduce a security problem-- for example,
an untrusted socket factory class with the same name defined by a
different class loader could be used to steal cached connections
created by your socket factory class.  But when looking up cached
connections (or server sockets), the RMI implementation verifies
identical socket factory classes before invoking equals, because it
can't know which of two different factory classes is more trusted-- so
it wouldn't work anyway.

The equals implementation above is correct (assuming, of course, that
the socket factory class does not have any instance state).

-- Peter

===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff RMI-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".

For a list of frequently asked RMI questions please refer to:
http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html

To view past RMI-USERS postings, please see:
http://archives.java.sun.com/archives/rmi-users.html