[ 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 (Settings changed) made by wkharold 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: Closed >Resolution: Fixed 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. ---------------------------------------------------------------------- Comment By: Eamonn McManus (emcmanus) Date: 2003-10-27 09:42 Message: Logged In: YES user_id=770046 Alternatively, use a HashMap internally, and convert to and from Hashtable where required by the API. HashMap is not synchronized, and doesn't need to be since the contents will be immutable. ---------------------------------------------------------------------- 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/