[ mx4j-Bugs-831072 ] ObjectName equals() can deadlock on SMP machines

"SourceForge.net" <[email protected]>
Newsgroups gmane.comp.java.mx4j.devel
Message-ID <[email protected]>
Bugs item #831072, was opened at 2003-10-27 09:28
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=450647&aid=831072&group_id=47745

Category: JMX implementation
Group: Release 1.1.1 beta1
Status: Open
Resolution: None
Priority: 5
Submitted By: Ward K Harold (wkharold)
Assigned to: Ward K Harold (wkharold)
Summary: ObjectName equals() can deadlock on SMP machines

Initial Comment:
The ObjectName equals() method uses the Hashtable
equals method to test the key property sets for
equality. This can result in a deadlock on SMP
machines. For example, assume two threads A and B
compare ObjectNames X and Y as follows:

A calls X.equals(Y)
B calls Y.equals(X)

The first invocation ultimately calls:

X.properties.equals(Y.properties) 

which acquires the monitor lock on X.properties.

The second invocation ultimately calls:

Y.properties.equals(X.properties) 

which acquires the monitor lock on Y.properties.

The implementation of the Hashtable equals() method
calls get(), which is also synchronized. This can lead
to a classic deadlock situation in which A has acquired
X's monitor lock and is waiting on Y's monitor lock
while B holds Y's monitor lock and is waiting on X's
monitor lock.

This is a known liveness issue with Hashtable:

http://developer.java.sun.com/developer/bugParade/bugs/4211002.html
http://java.sun.com/products/jdk/1.2/compatibility.html#api

The simplest solution is to clone the key properties
Hashtable of the ObjectName passed as a parameter to
the equals method.



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=450647&aid=831072&group_id=47745


-------------------------------------------------------
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community?  Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.