This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 598e8c3  (chores) camel-consul: avoid using generic exceptions (#5827)
598e8c3 is described below

commit 598e8c3839a668832381ffce48cc0bb2385e7a24
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Mon Jul 12 17:25:54 2021 +0200

    (chores) camel-consul: avoid using generic exceptions (#5827)
---
 .../org/apache/camel/component/consul/ConsulClientConfiguration.java | 4 +++-
 .../main/java/org/apache/camel/component/consul/ConsulRegistry.java  | 4 ++--
 .../camel/component/consul/endpoint/AbstractConsulProducer.java      | 5 +++--
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/ConsulClientConfiguration.java
 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/ConsulClientConfiguration.java
index b8d85de..0c690ee 100644
--- 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/ConsulClientConfiguration.java
+++ 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/ConsulClientConfiguration.java
@@ -16,7 +16,9 @@
  */
 package org.apache.camel.component.consul;
 
+import java.io.IOException;
 import java.math.BigInteger;
+import java.security.GeneralSecurityException;
 import java.time.Duration;
 import java.util.Collections;
 import java.util.HashSet;
@@ -352,7 +354,7 @@ public abstract class ConsulClientConfiguration implements 
Cloneable {
         return createConsulClient(null);
     }
 
-    public Consul createConsulClient(CamelContext camelContext) throws 
Exception {
+    public Consul createConsulClient(CamelContext camelContext) throws 
GeneralSecurityException, IOException {
         Consul.Builder builder = Consul.builder();
         builder.withPing(pingInstance);
 
diff --git 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/ConsulRegistry.java
 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/ConsulRegistry.java
index 5aae114..88d7187 100644
--- 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/ConsulRegistry.java
+++ 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/ConsulRegistry.java
@@ -286,7 +286,7 @@ public class ConsulRegistry implements Registry {
             try (ObjectInputStream in = new ObjectInputStream(new 
ByteArrayInputStream(bytes))) {
                 return in.readObject();
             } catch (IOException | ClassNotFoundException e) {
-                throw new RuntimeException(e);
+                throw new RuntimeCamelException(e);
             }
         }
 
@@ -312,7 +312,7 @@ public class ConsulRegistry implements Registry {
                 out.writeObject(serializable);
                 return baos.toByteArray();
             } catch (IOException e) {
-                throw new RuntimeException(e);
+                throw new RuntimeCamelException(e);
             }
         }
     }
diff --git 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/AbstractConsulProducer.java
 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/AbstractConsulProducer.java
index 5343d12..4adf514 100644
--- 
a/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/AbstractConsulProducer.java
+++ 
b/components/camel-consul/src/main/java/org/apache/camel/component/consul/endpoint/AbstractConsulProducer.java
@@ -66,11 +66,12 @@ abstract class AbstractConsulProducer<C> extends 
HeaderSelectorProducer {
         return configuration;
     }
 
-    protected <D> D getMandatoryHeader(Message message, String header, 
Class<D> type) throws Exception {
+    protected <D> D getMandatoryHeader(Message message, String header, 
Class<D> type) throws NoSuchHeaderException {
         return getMandatoryHeader(message, header, (D) null, type);
     }
 
-    protected <D> D getMandatoryHeader(Message message, String header, D 
defaultValue, Class<D> type) throws Exception {
+    protected <D> D getMandatoryHeader(Message message, String header, D 
defaultValue, Class<D> type)
+            throws NoSuchHeaderException {
         D value = message.getHeader(header, defaultValue, type);
         if (value == null) {
             throw new NoSuchHeaderException(message.getExchange(), header, 
type);

Reply via email to