JDK-6566891 : RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
  • Type: Bug
  • Component: core-svc
  • Sub-Component: javax.management
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2007-06-07
  • Updated: 2014-02-12
  • Resolved: 2013-08-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
7u60Fixed 8 b108Fixed
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.

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;

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.