/** * Gets a usable MBeanServerConnection. * * Method is threadsafe. * * @returns the MBeanServerConnection * @throws IllegalStateException if not connected. */ private synchronized MBeanServerConnection getConnectionOrFail() { if (isConnected()) return getConnection(); if (triedConnecting) { throw new IllegalStateException("Failed to connect to JMX at "+url); } else { String msg = "Not connected (and not attempted to connect) to JMX at "+url+ (failedReconnecting ? (" (last reconnect failure at "+ Time.makeDateString(failedReconnectingTime) + ")") : ""); throw new IllegalStateException(msg); } }