summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--java/management/common/src/main/java/org/apache/qpid/management/common/JMXConnnectionFactory.java79
-rw-r--r--java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java2
2 files changed, 47 insertions, 34 deletions
diff --git a/java/management/common/src/main/java/org/apache/qpid/management/common/JMXConnnectionFactory.java b/java/management/common/src/main/java/org/apache/qpid/management/common/JMXConnnectionFactory.java
index f5831c9e28..c03b782987 100644
--- a/java/management/common/src/main/java/org/apache/qpid/management/common/JMXConnnectionFactory.java
+++ b/java/management/common/src/main/java/org/apache/qpid/management/common/JMXConnnectionFactory.java
@@ -199,25 +199,32 @@ public class JMXConnnectionFactory {
Thread connectorThread = new Thread(connector);
connectorThread.start();
connectorThread.join(timeout);
-
- if (connector.getConnectionException() != null)
+
+ if(connector.getJmxc() == null)
{
- throw connector.getConnectionException();
+ if (connector.getConnectionException() != null)
+ {
+ throw connector.getConnectionException();
+ }
+ else
+ {
+ throw new IOException("Timed out connecting to " + host + ":" + port);
+ }
}
+
return connector.getJmxc();
}
- public static class ConnectWaiter implements Runnable
+ private static class ConnectWaiter implements Runnable
{
- private boolean _connected;
private Exception _connectionException;
private JMXConnector _jmxc;
private JMXServiceURL _jmxUrl;
private Map<String, ?> _env;
+ private boolean _connectionRetrieved;
public ConnectWaiter(JMXServiceURL url, Map<String, ?> env)
{
- super();
_jmxUrl = url;
_env = env;
}
@@ -226,46 +233,52 @@ public class JMXConnnectionFactory {
{
try
{
- setConnected(false);
- setConnectionException(null);
- setJmxc(JMXConnectorFactory.connect(_jmxUrl, _env));
-
- setConnected(true);
+ _jmxc = null;
+ _connectionRetrieved = false;
+ _connectionException = null;
+
+ JMXConnector conn = JMXConnectorFactory.connect(_jmxUrl, _env);
+
+ synchronized (this)
+ {
+ if(_connectionRetrieved)
+ {
+ //The app thread already timed out the attempt and retrieved the
+ //null connection, so just close this orphaned connection
+ try
+ {
+ conn.close();
+ }
+ catch (IOException e)
+ {
+ //ignore
+ }
+ }
+ else
+ {
+ _jmxc = conn;
+ }
+ }
}
catch (Exception ex)
{
- setConnectionException(ex);
+ _connectionException = ex;
}
}
- public void setConnected(boolean _connected)
- {
- this._connected = _connected;
- }
-
- public boolean getConnected()
- {
- return _connected;
- }
-
- public void setConnectionException(Exception _connectionException)
- {
- this._connectionException = _connectionException;
- }
-
public Exception getConnectionException()
{
return _connectionException;
}
- public void setJmxc(JMXConnector _jmxc)
- {
- this._jmxc = _jmxc;
- }
-
public JMXConnector getJmxc()
{
- return _jmxc;
+ synchronized (this)
+ {
+ _connectionRetrieved = true;
+
+ return _jmxc;
+ }
}
}
}
diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java
index 0f5f5267fd..c22cfc4f45 100644
--- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java
+++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java
@@ -43,7 +43,7 @@ public abstract class ApplicationRegistry
private static ImageRegistry imageRegistry = new ImageRegistry();
private static FontRegistry fontRegistry = new FontRegistry();
public static final boolean debug = Boolean.getBoolean("eclipse.consoleLog");
- public static final long timeout = Long.parseLong(System.getProperty("timeout", "5000"));
+ public static final long timeout = Long.parseLong(System.getProperty("timeout", "15000"));
//max supported broker management interface supported by this release of the management console
public static final int SUPPORTED_QPID_JMX_API_MAJOR_VERSION = 1;