private synchronized void connectIfNecessary() { if (server == null || delegate.isConnected()) { return; } try { delegate.connect(server, connectionTimeout); } catch (IOException e) { LOGGER.warn("Auto-reconnect failed", e); } }
@Override public boolean isConnected() { connectIfNecessary(); return delegate.isConnected(); }