Author: bvahdat Date: Mon Nov 5 20:09:25 2012 New Revision: 1405932 URL: http://svn.apache.org/viewvc?rev=1405932&view=rev Log: CAMEL-5751: While stopping the QuickfixjEngine unregister the Connector MBean in the same way we do for the Initiator. Thanks to Christoph John providing this hint at http://www.quickfixj.org/jira/browse/QFJ-713. Also removed skipping the assert by QuickfixjEngineTest to see if this fixes the failing assert issue we're facing under JDK 7.
Modified: camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEngine.java camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjEngineTest.java Modified: camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEngine.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEngine.java?rev=1405932&r1=1405931&r2=1405932&view=diff ============================================================================== --- camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEngine.java (original) +++ camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEngine.java Mon Nov 5 20:09:25 2012 @@ -96,6 +96,7 @@ public class QuickfixjEngine extends Ser private final MessageCorrelator messageCorrelator = new MessageCorrelator(); private List<QuickfixjEventListener> eventListeners = new CopyOnWriteArrayList<QuickfixjEventListener>(); private final String uri; + private ObjectName acceptorObjectName; private ObjectName initiatorObjectName; public enum ThreadModel { @@ -222,7 +223,7 @@ public class QuickfixjEngine extends Ser if (acceptor != null) { acceptor.start(); if (jmxExporter != null) { - jmxExporter.register(acceptor); + acceptorObjectName = jmxExporter.register(acceptor); } } if (initiator != null) { @@ -237,6 +238,10 @@ public class QuickfixjEngine extends Ser protected void doStop() throws Exception { if (acceptor != null) { acceptor.stop(); + + if (jmxExporter != null && acceptorObjectName != null) { + jmxExporter.getMBeanServer().unregisterMBean(acceptorObjectName); + } } if (initiator != null) { initiator.stop(); Modified: camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjEngineTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjEngineTest.java?rev=1405932&r1=1405931&r2=1405932&view=diff ============================================================================== --- camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjEngineTest.java (original) +++ camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjEngineTest.java Mon Nov 5 20:09:25 2012 @@ -564,14 +564,9 @@ public class QuickfixjEngineTest extends assertThat(quickfixjEngine.getLogFactory(), instanceOf(ScreenLogFactory.class)); assertThat(quickfixjEngine.getMessageFactory(), instanceOf(DefaultMessageFactory.class)); - if (isJava17()) { - // TODO: just from time to time the assert below fails on JDK 7 - return; - } - MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer(); - Set<ObjectName> names = mbeanServer.queryNames(new ObjectName("org.quickfixj:type=Connector,role=Acceptor,*"), null); - assertTrue("QFJ mbean should not have been registered", names.isEmpty()); + Set<ObjectName> names = mbeanServer.queryNames(new ObjectName("org.quickfixj:*"), null); + assertTrue("QFJ Connector/Initiator mbeans should not have been registered", names.isEmpty()); } private void writeSettings() throws IOException {