[JAVA-584] In DBPortPool the PlatformMBeanServer can collide with other connection pool object names Created: 06/Jun/12  Updated: 07/Mar/14  Resolved: 07/Mar/14

Status: Closed
Project: Java Driver
Component/s: Monitoring
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Ryan Nitz Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates JAVA-330 Add lock/unlock helper to Mongo inter... Closed
is duplicated by JAVA-926 multiple Mongo instances for same hos... Closed

 Description   

In DBPortPool, this pulls the global MBean server:

temp = ManagementFactory.getPlatformMBeanServer();

The object name is created here:

        private ObjectName createObjectName( ServerAddress addr ) throws MalformedObjectNameException {
            String name =  "com.mongodb:type=ConnectionPool,host=" + addr.toString().replace( ":" , ",port=" ) + ",instance=" + _serial;
            if ( _options.description != null )
                name += ",description=" + _options.description;
            return new ObjectName( name );
        }

If you have multiple Mongo objects connecting to the same server, there can be collision because the _serial values start at the same counter (zero). This could be a problem if multiple web-apps are hosted in the same JVM (and connect to the same server).

Adding thread id may help with this...



 Comments   
Comment by Jeffrey Yemin [ 26/Nov/13 ]

I would rather just use a UUID.

Generated at Thu Feb 08 08:52:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.