@@ -176,7 +176,8 @@ public JMXConnector connect(Object credentials) {
176176 long connectStartTime = System .currentTimeMillis ();
177177 System .err .println ("[JMX-CONNECT] Starting JMX connection at " + java .time .Instant .now ());
178178 System .err .println ("[JMX-CONNECT] Thread: " + Thread .currentThread ().getName ());
179- System .err .println ("[JMX-CONNECT] Credentials type: " + (credentials != null ? credentials .getClass ().getName () : "null" ));
179+ System .err .println ("[JMX-CONNECT] Credentials type: "
180+ + (credentials != null ? credentials .getClass ().getName () : "null" ));
180181 try {
181182
182183 String jmxSerURL = "" ;
@@ -224,33 +225,38 @@ public JMXConnector connect(Object credentials) {
224225 env .put ("com.sun.jndi.rmi.factory.socket" , new SslRMIClientSocketFactory ());
225226 }
226227 logger .info ("Connecting to jmxURL : {}" , jmxSerURL );
227- System .err .println ("[JMX-CONNECT] Attempting JMXConnectorFactory.connect() to: " + jmxSerURL );
228+ System .err
229+ .println ("[JMX-CONNECT] Attempting JMXConnectorFactory.connect() to: " + jmxSerURL );
228230 System .err .println ("[JMX-CONNECT] With SSL: " + repository .isUseSSLManager ());
229231 long jmxCallStart = System .currentTimeMillis ();
230232 conn = JMXConnectorFactory .connect (url , env );
231233 long jmxCallEnd = System .currentTimeMillis ();
232- System .err .println ("[JMX-CONNECT] JMXConnectorFactory.connect() successful in " + (jmxCallEnd - jmxCallStart ) + "ms" );
234+ System .err .println ("[JMX-CONNECT] JMXConnectorFactory.connect() successful in "
235+ + (jmxCallEnd - jmxCallStart ) + "ms" );
233236 mbs = conn .getMBeanServerConnection ();
234237 cluster .setConnectedFlag (true );
238+ long totalDuration = System .currentTimeMillis () - connectStartTime ;
239+ System .err .println ("[JMX-CONNECT] Total connection time: " + totalDuration + "ms" );
240+ } finally {
241+ System .setProperties (originalProperties );
242+ }
243+ }
244+ } catch (Exception e ) {
235245 long totalDuration = System .currentTimeMillis () - connectStartTime ;
236246 cluster .setConnectedFlag (false );
237247 cluster .setConnectionErrorMsg (e .getMessage ());
238248 System .err .println ("[JMX-CONNECT] Connection FAILED after " + totalDuration + "ms" );
239249 System .err .println ("[JMX-CONNECT] Exception type: " + e .getClass ().getName ());
240250 System .err .println ("[JMX-CONNECT] Exception message: " + e .getMessage ());
241251 if (e .getCause () != null ) {
242- System .err .println ("[JMX-CONNECT] Caused by: " + e .getCause ().getClass ().getName () + ": " + e .getCause ().getMessage ());
252+ System .err .println ("[JMX-CONNECT] Caused by: " + e .getCause ().getClass ().getName () + ": "
253+ + e .getCause ().getMessage ());
243254 if (e .getCause ().getCause () != null ) {
244- System .err .println ("[JMX-CONNECT] Caused by: " + e .getCause ().getCause ().getClass ().getName () + ": " + e .getCause ().getCause ().getMessage ());
245- }
246- }nnection time : " + totalDuration + "ms" );
247- } finally {
248- System .setProperties (originalProperties );
255+ System .err
256+ .println ("[JMX-CONNECT] Caused by: " + e .getCause ().getCause ().getClass ().getName ()
257+ + ": " + e .getCause ().getCause ().getMessage ());
249258 }
250259 }
251- } catch (Exception e ) {
252- cluster .setConnectedFlag (false );
253- cluster .setConnectionErrorMsg (e .getMessage ());
254260 logger .fatal (e .getMessage (), e );
255261 if (conn != null ) {
256262 try {
0 commit comments