Author: jim.ma
Date: 2013-05-17 04:02:15 -0400 (Fri, 17 May 2013)
New Revision: 17592
Modified:
shared-testsuite/branches/jbossws-shared-testsuite-4.1.x/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java
Log:
[BZ-927881]:Workaround to add more tries to get connection
Modified:
shared-testsuite/branches/jbossws-shared-testsuite-4.1.x/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java
===================================================================
---
shared-testsuite/branches/jbossws-shared-testsuite-4.1.x/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java 2013-05-16
12:29:55 UTC (rev 17591)
+++
shared-testsuite/branches/jbossws-shared-testsuite-4.1.x/src/main/java/org/jboss/wsf/test/JBossWSTestHelper.java 2013-05-17
08:02:15 UTC (rev 17592)
@@ -32,6 +32,7 @@
import java.util.Map;
import javax.management.MBeanServerConnection;
+import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import javax.xml.namespace.QName;
@@ -244,12 +245,39 @@
{
String host = getServerHost();
String urlString = System.getProperty("jmx.service.url",
"service:jmx:remoting-jmx://" + host + ":" + 9999);
- try {
- JMXServiceURL serviceURL = new JMXServiceURL(urlString);
- return JMXConnectorFactory.connect(serviceURL,
null).getMBeanServerConnection();
- } catch (IOException ex) {
- throw new IllegalStateException("Cannot obtain MBeanServerConnection to:
" + urlString, ex);
+ JMXServiceURL serviceURL = null;
+ JMXConnector connector = null;
+ try
+ {
+ serviceURL = new JMXServiceURL(urlString);
}
+ catch (MalformedURLException e1)
+ {
+ //NO_OP
+ }
+ //add more tries to get the connection. Workaround to fix some test failures
caused by connection is not established in 5 seconds
+ for (int i = 0 ; i < 5; i++) {
+ try {
+ connector = JMXConnectorFactory.connect(serviceURL, null);
+ } catch (IOException ex) {
+ throw new IllegalStateException("Cannot obtain MBeanServerConnection
to: " + urlString, ex);
+ } catch (RuntimeException e) {
+ if (e.getMessage().contains("WAITING")) {
+ continue;
+ } else {
+ throw e;
+ }
+ }
+ }
+
+ try
+ {
+ return connector.getMBeanServerConnection();
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException("Cannot obtain MBeanServerConnection to:
" + urlString, e);
+ }
}
public static String getIntegrationTarget()