2121
2222import java .io .IOException ;
2323import java .net .ConnectException ;
24+ import java .security .KeyManagementException ;
25+ import java .security .NoSuchAlgorithmException ;
2426import java .util .Map ;
2527import java .util .UUID ;
2628import java .util .concurrent .ConcurrentHashMap ;
2729import java .util .concurrent .ExecutorService ;
2830import java .util .concurrent .Executors ;
31+ import java .util .concurrent .TimeoutException ;
2932
3033import javax .naming .ConfigurationException ;
3134
@@ -358,17 +361,16 @@ private synchronized Connection getConnection() throws Exception {
358361 if (s_connection == null ) {
359362 try {
360363 return createConnection ();
361- } catch (Exception e ) {
362- s_logger .error ("Failed to create a connection to AMQP server due to " + e . getMessage ( ));
364+ } catch (KeyManagementException | NoSuchAlgorithmException | IOException | TimeoutException e ) {
365+ s_logger .error (String . format ( "Failed to create a connection to AMQP server [AMQP host:%s, port:%d] due to: %s" , amqpHost , port , e ));
363366 throw e ;
364367 }
365368 } else {
366369 return s_connection ;
367370 }
368371 }
369372
370- private synchronized Connection createConnection () throws Exception {
371- try {
373+ private synchronized Connection createConnection () throws KeyManagementException , NoSuchAlgorithmException , IOException , TimeoutException {
372374 ConnectionFactory factory = new ConnectionFactory ();
373375 factory .setUsername (username );
374376 factory .setPassword (password );
@@ -389,9 +391,6 @@ private synchronized Connection createConnection() throws Exception {
389391 connection .addBlockedListener (blockedConnectionHandler );
390392 s_connection = connection ;
391393 return s_connection ;
392- } catch (Exception e ) {
393- throw e ;
394- }
395394 }
396395
397396 private synchronized void closeConnection () {
0 commit comments