416990 JMX names statically unique
Fixed monitor test to reset uniqueness
This commit is contained in:
parent
c842c5c505
commit
3eb84f99a4
|
@ -49,7 +49,15 @@ import org.eclipse.jetty.util.thread.ShutdownThread;
|
||||||
public class MBeanContainer extends AbstractLifeCycle implements Container.Listener, Dumpable
|
public class MBeanContainer extends AbstractLifeCycle implements Container.Listener, Dumpable
|
||||||
{
|
{
|
||||||
private final static Logger LOG = Log.getLogger(MBeanContainer.class.getName());
|
private final static Logger LOG = Log.getLogger(MBeanContainer.class.getName());
|
||||||
private final static HashMap<String, Integer> _unique = new HashMap<String, Integer>();
|
private final static HashMap<String, Integer> __unique = new HashMap<String, Integer>();
|
||||||
|
|
||||||
|
public final static void resetUnique()
|
||||||
|
{
|
||||||
|
synchronized (__unique)
|
||||||
|
{
|
||||||
|
__unique.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final MBeanServer _server;
|
private final MBeanServer _server;
|
||||||
private final WeakHashMap<Object, ObjectName> _beans = new WeakHashMap<Object, ObjectName>();
|
private final WeakHashMap<Object, ObjectName> _beans = new WeakHashMap<Object, ObjectName>();
|
||||||
|
@ -283,9 +291,13 @@ public class MBeanContainer extends AbstractLifeCycle implements Container.Liste
|
||||||
}
|
}
|
||||||
|
|
||||||
String basis = buf.toString();
|
String basis = buf.toString();
|
||||||
Integer count = _unique.get(basis);
|
Integer count;
|
||||||
count = count == null ? 0 : 1 + count;
|
synchronized (__unique)
|
||||||
_unique.put(basis, count);
|
{
|
||||||
|
count = __unique.get(basis);
|
||||||
|
count = count == null ? 0 : 1 + count;
|
||||||
|
__unique.put(basis, count);
|
||||||
|
}
|
||||||
|
|
||||||
//if no explicit domain, create one
|
//if no explicit domain, create one
|
||||||
String domain = _domain;
|
String domain = _domain;
|
||||||
|
|
|
@ -97,6 +97,7 @@ public class AttrEventTriggerTest
|
||||||
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
|
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
|
||||||
MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
|
MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
|
||||||
mBeanContainer.addBean(Log.getLog());
|
mBeanContainer.addBean(Log.getLog());
|
||||||
|
MBeanContainer.resetUnique();
|
||||||
|
|
||||||
_counter = _handler.getRequestCounter();
|
_counter = _handler.getRequestCounter();
|
||||||
mBeanContainer.addBean(_counter);
|
mBeanContainer.addBean(_counter);
|
||||||
|
|
Loading…
Reference in New Issue