United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6566891 : RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed

Details
Type:
Bug
Submit Date:
2007-06-07
Status:
Closed
Updated Date:
2014-02-12
Project Name:
JDK
Resolved Date:
2013-08-30
Component:
core-svc
OS:
generic
Sub-Component:
javax.management
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:
Backport:

Sub Tasks

Description
The RMIConnector class defines a WeakHashMap that keeps an MBeanServerConnection
per delegation subject. The problem is that the MBeanServerConnection internally
holds a reference to the delegation subject, i.e. the WeakHashMap key, thus preventing
a given entry to be removed unless both the delegation subject and MBeanServerConnection
instances get nulled.

                                    

Comments
URL:   http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/2d51653d9b4b
User:  lana
Date:  2013-09-18 00:31:25 +0000

                                     
2013-09-18
URL:   http://hg.openjdk.java.net/jdk8/tl/jdk/rev/2d51653d9b4b
User:  sjiang
Date:  2013-08-30 11:16:52 +0000

                                     
2013-08-30
SUGGESTED FIX

Put the MBeanServerConnection into a WeakReference before saving it into the map.

Change:
    private transient WeakHashMap<Subject, MBeanServerConnection> rmbscMap;
into:
    private transient WeakHashMap<Subject, WeakReference<MBeanServerConnection>> rmbscMap;
                                     
2007-06-07
EVALUATION

The entries in the WeakHashMap are not removed when the delegation subject (the map key)
gets nulled however all the map entries are removed when RMIConnector.close() is called.
                                     
2007-06-07



Hardware and Software, Engineered to Work Together