/** * <p>Returns the string representation of this exception. The string * representation contains this exception's class name, its detailed * messsage, and if it has a <i>root</i> exception, the string representation * of the root exception. This string representation is meant for debugging * and is not meant to be interpreted programmatically.</p> * * @return the non-null string representation of this exception. * @see Throwable#getMessage() */ public String toString() { StringBuffer sb = new StringBuffer(this.getClass().getName()) .append(": ").append(super.toString()); if (cause != null) { sb.append("; caused by: ").append(cause.toString()); } return sb.toString(); } }
throw new IOException(ex.toString()); } catch (KeyManagementException ex) { throw new IOException(ex.toString());
private HttpClient getHttpClient() { HttpClientBuilder builder = HttpClientBuilder.create().useSystemProperties(); if (this.ignoreSsl) { try { SSLContextBuilder sslContextBuilder = new SSLContextBuilder(); sslContextBuilder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContextBuilder.build(), NoopHostnameVerifier.INSTANCE); builder.setSSLSocketFactory(sslsf); } catch (NoSuchAlgorithmException e) { logger.log(Level.SEVERE, "Failing to setup the SSLConnectionFactory: " + e.toString()); throw new RuntimeException(e); } catch (KeyStoreException e) { logger.log(Level.SEVERE, "Failing to setup the SSLConnectionFactory: " + e.toString()); throw new RuntimeException(e); } catch (KeyManagementException e) { logger.log(Level.SEVERE, "Failing to setup the SSLConnectionFactory: " + e.toString()); throw new RuntimeException(e); } } return builder.build(); }
stdErr.println("[!] NoSuchAlgorithmException: " + ex.toString().trim()); } catch (KeyManagementException ex) { stdErr.println("[!] KeyManagementException: " + ex.toString().trim());
private void testRabbitMQConnection() { Connection connection; factory.setHost(hostname); factory.setPort(port); factory.setVirtualHost(virtualHost); factory.setUsername(username); factory.setPassword(password); if (enableSSL) { try { factory.useSslProtocol(); } catch (NoSuchAlgorithmException ex) { throw new IllegalArgumentException("Could not Enable SSL: " + ex.toString()); } catch (KeyManagementException ex) { throw new IllegalArgumentException("Could not Enable SSL: " + ex.toString()); } } try { connection = factory.newConnection(); connection.close(); } catch (IOException ex) { throw new IllegalArgumentException("Could not connect to RabbitMQ: " + ex.toString()); } }
private Connection createRabbitMQConnection(ConnectionFactory factory) throws EventDeliveryException { logger.debug("Connecting to RabbitMQ from {}", this.getName()); counterGroup.incrementAndGet(RABBITMQ_CONNECTED); factory.setHost(hostname); factory.setPort(port); factory.setVirtualHost(virtualHost); factory.setUsername(username); factory.setPassword(password); if (sslEnabled) { try { factory.useSslProtocol(); } catch (NoSuchAlgorithmException ex) { counterGroup.incrementAndGet(RABBITMQ_EXCEPTION_SSL); logger.error("Could not enable SSL: {}", ex.toString()); throw new EventDeliveryException("Could not Enable SSL: " + ex.toString()); } catch (KeyManagementException ex) { counterGroup.incrementAndGet(RABBITMQ_EXCEPTION_SSL); logger.error("Could not enable SSL: {}", ex.toString()); throw new EventDeliveryException("Could not Enable SSL: " + ex.toString()); } } try { return factory.newConnection(); } catch (IOException ex) { counterGroup.incrementAndGet(RABBITMQ_EXCEPTION_CONNECTION); throw new EventDeliveryException(ex.toString()); } }
private Connection createRabbitMQConnection(Config config) throws IOException { logger.debug("Connecting to RabbitMQ from {}", this); config = config.withRecoveryPolicy(RecoveryPolicies.recoverAlways()) .withRetryPolicy(new RetryPolicy() .withMaxAttempts(200) .withInterval(Duration.seconds(1)) .withMaxDuration(Duration.minutes(5))); ConnectionOptions options = new ConnectionOptions() .withHost(hostname) .withPort(port) .withVirtualHost(virtualHost) .withUsername(username) .withPassword(password) ; if (sslEnabled) { try { options = options.withSsl(); } catch (NoSuchAlgorithmException e) { logger.error("Could not enable SSL: {}", e.toString()); } catch (KeyManagementException e) { logger.error("Could not enable SSL: {}", e.toString()); } } try { return Connections.create(options, config); } catch (java.util.concurrent.TimeoutException e) { logger.error("Timeout connecting to RabbitMQ: {}", e.toString()); throw new IOException(); } }