You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2022/10/19 07:17:13 UTC

[camel] branch main updated (62f1dddb715 -> 850df98da47)

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

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


    from 62f1dddb715 Align archetypes to JDK 11 requirement, use <release> instead of <source> and <target>
     new 867c80f6777 (chores) camel-base-engine: use standard check for exception type in catch blocks
     new 90f33d5a51a (chores) camel-support: use standard check for exception type in catch blocks
     new 2c38bde73ef (chores) camel-tooling: use standard check for exception type in catch blocks
     new 99c4ba1c529 (chores) camel-bean: use standard check for exception type in catch blocks
     new 8b38194b54f (chores) camel-spring: use standard check for exception type in catch blocks
     new edd109b5e5c (chores) camel-spring-xml: use standard check for exception type in catch blocks
     new db3b93b53b5 (chores) camel-json-validator: use standard check for exception type in catch blocks
     new 6d0bba94297 (chores) camel-openapi-java: use standard check for exception type in catch blocks
     new 850df98da47 (chores) camel-swagger-java: use standard check for exception type in catch blocks

The 9 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/camel/language/bean/BeanExpression.java |  5 ++---
 .../component/jsonvalidator/JsonValidatorEndpoint.java      | 11 ++++-------
 .../java/org/apache/camel/openapi/RestOpenApiReader.java    | 10 ++++------
 .../org/apache/camel/spring/xml/CamelBeanPostProcessor.java | 12 ++++--------
 .../org/apache/camel/spring/spi/CamelBeanPostProcessor.java |  6 ++----
 .../java/org/apache/camel/swagger/RestSwaggerReader.java    | 12 ++++--------
 .../org/apache/camel/impl/engine/AbstractCamelContext.java  |  5 ++---
 .../org/apache/camel/support/component/ApiMethodHelper.java | 13 ++++++++-----
 .../camel/generator/openapi/RestDefinitionEmitter.java      |  7 ++-----
 .../camel/generator/swagger/RestDefinitionEmitter.java      |  9 +++------
 10 files changed, 35 insertions(+), 55 deletions(-)


[camel] 08/09: (chores) camel-openapi-java: use standard check for exception type in catch blocks

Posted by or...@apache.org.
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

commit 6d0bba942974413788968ef09e5fe126b4c4259b
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Oct 18 16:54:38 2022 +0200

    (chores) camel-openapi-java: use standard check for exception type in catch blocks
---
 .../main/java/org/apache/camel/openapi/RestOpenApiReader.java  | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/components/camel-openapi-java/src/main/java/org/apache/camel/openapi/RestOpenApiReader.java b/components/camel-openapi-java/src/main/java/org/apache/camel/openapi/RestOpenApiReader.java
index 2716f6806a1..e6ed424d6fc 100644
--- a/components/camel-openapi-java/src/main/java/org/apache/camel/openapi/RestOpenApiReader.java
+++ b/components/camel-openapi-java/src/main/java/org/apache/camel/openapi/RestOpenApiReader.java
@@ -1082,18 +1082,16 @@ public class RestOpenApiReader {
             final List<?> values = allowableValues.stream().map(v -> {
                 try {
                     return valueOf.invoke(v);
+                } catch (RuntimeException e) {
+                    throw e;
                 } catch (Throwable e) {
-                    if (e instanceof RuntimeException) {
-                        throw (RuntimeException) e;
-                    }
                     throw new IllegalStateException(e);
                 }
             }).collect(Collectors.toList());
             setEnum.invoke(values);
+        } catch (RuntimeException e) {
+            throw e;
         } catch (Throwable e) {
-            if (e instanceof RuntimeException) {
-                throw (RuntimeException) e;
-            }
             throw new IllegalStateException(e);
         }
     }


[camel] 03/09: (chores) camel-tooling: use standard check for exception type in catch blocks

Posted by or...@apache.org.
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

commit 2c38bde73ef18d3aa8f2beb6c6742de2927c2a40
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Oct 18 16:49:32 2022 +0200

    (chores) camel-tooling: use standard check for exception type in catch blocks
---
 .../apache/camel/generator/openapi/RestDefinitionEmitter.java    | 7 ++-----
 .../apache/camel/generator/swagger/RestDefinitionEmitter.java    | 9 +++------
 2 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/tooling/openapi-rest-dsl-generator/src/main/java/org/apache/camel/generator/openapi/RestDefinitionEmitter.java b/tooling/openapi-rest-dsl-generator/src/main/java/org/apache/camel/generator/openapi/RestDefinitionEmitter.java
index d0b3364896f..21a67a9b219 100644
--- a/tooling/openapi-rest-dsl-generator/src/main/java/org/apache/camel/generator/openapi/RestDefinitionEmitter.java
+++ b/tooling/openapi-rest-dsl-generator/src/main/java/org/apache/camel/generator/openapi/RestDefinitionEmitter.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.generator.openapi;
 
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -45,11 +46,7 @@ class RestDefinitionEmitter implements CodeEmitter<RestsDefinition> {
             final Method declaredMethod = type.getMethod(method, parameterTypesOf(arguments));
 
             variable = declaredMethod.invoke(variable, arguments);
-        } catch (final Exception e) {
-            if (e instanceof RuntimeException) {
-                throw (RuntimeException) e;
-            }
-
+        } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
             throw new IllegalStateException(e);
         }
 
diff --git a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDefinitionEmitter.java b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDefinitionEmitter.java
index 8e5f1846688..796012aab02 100644
--- a/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDefinitionEmitter.java
+++ b/tooling/swagger-rest-dsl-generator/src/main/java/org/apache/camel/generator/swagger/RestDefinitionEmitter.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.generator.swagger;
 
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -46,12 +47,8 @@ class RestDefinitionEmitter implements CodeEmitter<RestsDefinition> {
             final Method declaredMethod = type.getMethod(method, parameterTypesOf(arguments));
 
             variable = declaredMethod.invoke(variable, arguments);
-        } catch (final Exception e) {
-            if (e instanceof RuntimeException) {
-                throw (RuntimeException) e;
-            } else {
-                throw new IllegalStateException(e);
-            }
+        } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
+            throw new IllegalStateException(e);
         }
 
         return this;


[camel] 02/09: (chores) camel-support: use standard check for exception type in catch blocks

Posted by or...@apache.org.
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

commit 90f33d5a51aa3150a94129d9885aef9e540234d9
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Oct 18 16:42:54 2022 +0200

    (chores) camel-support: use standard check for exception type in catch blocks
---
 .../org/apache/camel/support/component/ApiMethodHelper.java | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/core/camel-support/src/main/java/org/apache/camel/support/component/ApiMethodHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/component/ApiMethodHelper.java
index a019b2ceb8a..56a829d08a9 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/component/ApiMethodHelper.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/component/ApiMethodHelper.java
@@ -521,12 +521,15 @@ public final class ApiMethodHelper<T extends Enum<T> & ApiMethod> {
 
         try {
             return method.getMethod().invoke(proxy, values);
+        } catch (InvocationTargetException e) {
+            final Throwable cause = e.getCause();
+
+            String message = cause != null ? cause.getMessage() : e.getMessage();
+
+            throw new RuntimeCamelException(
+                    String.format("Error invoking %s with %s: %s", method.getName(), properties, message),
+                    cause != null ? cause : e);
         } catch (Throwable e) {
-            if (e instanceof InvocationTargetException) {
-                // get API exception
-                final Throwable cause = e.getCause();
-                e = (cause != null) ? cause : e;
-            }
             throw new RuntimeCamelException(
                     String.format("Error invoking %s with %s: %s", method.getName(), properties, e.getMessage()), e);
         }


[camel] 09/09: (chores) camel-swagger-java: use standard check for exception type in catch blocks

Posted by or...@apache.org.
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

commit 850df98da478096f347e13d53cedcd4026aa6757
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Oct 18 16:55:13 2022 +0200

    (chores) camel-swagger-java: use standard check for exception type in catch blocks
---
 .../java/org/apache/camel/swagger/RestSwaggerReader.java     | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerReader.java b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerReader.java
index 22161ddd336..0a4e6389fb8 100644
--- a/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerReader.java
+++ b/components/camel-swagger-java/src/main/java/org/apache/camel/swagger/RestSwaggerReader.java
@@ -473,20 +473,16 @@ public class RestSwaggerReader {
             final List<?> values = allowableValues.stream().map(v -> {
                 try {
                     return valueOf.invoke(v);
+                } catch (RuntimeException e) {
+                    throw e;
                 } catch (Throwable e) {
-                    if (e instanceof RuntimeException) {
-                        throw (RuntimeException) e;
-                    }
-
                     throw new IllegalStateException(e);
                 }
             }).collect(Collectors.toList());
             setEnum.invoke(values);
+        } catch (RuntimeException e) {
+            throw e;
         } catch (Throwable e) {
-            if (e instanceof RuntimeException) {
-                throw (RuntimeException) e;
-            }
-
             throw new IllegalStateException(e);
         }
     }


[camel] 06/09: (chores) camel-spring-xml: use standard check for exception type in catch blocks

Posted by or...@apache.org.
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

commit edd109b5e5cfc5d0bdee7c300590760399ec2d79
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Oct 18 16:53:16 2022 +0200

    (chores) camel-spring-xml: use standard check for exception type in catch blocks
---
 .../org/apache/camel/spring/xml/CamelBeanPostProcessor.java  | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/components/camel-spring-xml/src/main/java/org/apache/camel/spring/xml/CamelBeanPostProcessor.java b/components/camel-spring-xml/src/main/java/org/apache/camel/spring/xml/CamelBeanPostProcessor.java
index 9a34cf35d22..7bd845be278 100644
--- a/components/camel-spring-xml/src/main/java/org/apache/camel/spring/xml/CamelBeanPostProcessor.java
+++ b/components/camel-spring-xml/src/main/java/org/apache/camel/spring/xml/CamelBeanPostProcessor.java
@@ -170,11 +170,9 @@ public class CamelBeanPostProcessor
     public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
         try {
             return delegate.postProcessBeforeInitialization(bean, beanName);
+        } catch (BeansException e) {
+            throw e; // do not wrap already beans exceptions
         } catch (Exception e) {
-            // do not wrap already beans exceptions
-            if (e instanceof BeansException) {
-                throw (BeansException) e;
-            }
             throw new BeanCreationException("Error post processing bean: " + beanName, e);
         }
     }
@@ -183,11 +181,9 @@ public class CamelBeanPostProcessor
     public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
         try {
             return delegate.postProcessAfterInitialization(bean, beanName);
+        } catch (BeansException e) {
+            throw e; // do not wrap already beans exceptions
         } catch (Exception e) {
-            // do not wrap already beans exceptions
-            if (e instanceof BeansException) {
-                throw (BeansException) e;
-            }
             throw new BeanCreationException("Error post processing bean: " + beanName, e);
         }
     }


[camel] 05/09: (chores) camel-spring: use standard check for exception type in catch blocks

Posted by or...@apache.org.
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

commit 8b38194b54fcd57490fbf491bda1d0d9a446c7f0
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Oct 18 16:50:49 2022 +0200

    (chores) camel-spring: use standard check for exception type in catch blocks
---
 .../java/org/apache/camel/spring/spi/CamelBeanPostProcessor.java    | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/spi/CamelBeanPostProcessor.java b/components/camel-spring/src/main/java/org/apache/camel/spring/spi/CamelBeanPostProcessor.java
index e365d8d9137..3c50c04e5e3 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/spi/CamelBeanPostProcessor.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/spi/CamelBeanPostProcessor.java
@@ -171,11 +171,9 @@ public class CamelBeanPostProcessor
     public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
         try {
             return delegate.postProcessBeforeInitialization(bean, beanName);
+        } catch (BeansException e) {
+            throw e; // do not wrap already beans exceptions
         } catch (Exception e) {
-            // do not wrap already beans exceptions
-            if (e instanceof BeansException) {
-                throw (BeansException) e;
-            }
             throw new BeanCreationException("Error post processing bean: " + beanName, e);
         }
     }


[camel] 07/09: (chores) camel-json-validator: use standard check for exception type in catch blocks

Posted by or...@apache.org.
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

commit db3b93b53b5354c1ba04da0a3e696d8f1e437933
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Oct 18 16:53:53 2022 +0200

    (chores) camel-json-validator: use standard check for exception type in catch blocks
---
 .../camel/component/jsonvalidator/JsonValidatorEndpoint.java  | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidatorEndpoint.java b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidatorEndpoint.java
index 0642458be2f..5a86f61ee29 100644
--- a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidatorEndpoint.java
+++ b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidatorEndpoint.java
@@ -127,14 +127,11 @@ public class JsonValidatorEndpoint extends ResourceEndpoint {
                     }
                 }
             }
+        } catch (ValidationException e) {
+            throw e; // already as validation error
         } catch (Exception e) {
-            if (e instanceof ValidationException) {
-                // already as validation error
-                throw e;
-            } else {
-                // general error
-                this.errorHandler.handleErrors(exchange, schema, e);
-            }
+            // general error
+            this.errorHandler.handleErrors(exchange, schema, e);
         } finally {
             if (cache != null) {
                 cache.reset();


[camel] 01/09: (chores) camel-base-engine: use standard check for exception type in catch blocks

Posted by or...@apache.org.
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

commit 867c80f6777c5118cfd4bc09edcb3133c0a3cdad
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Oct 18 16:39:14 2022 +0200

    (chores) camel-base-engine: use standard check for exception type in catch blocks
---
 .../main/java/org/apache/camel/impl/engine/AbstractCamelContext.java | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index 08e61128a85..d085b2b1798 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -872,10 +872,9 @@ public abstract class AbstractCamelContext extends BaseService
         try {
             uri = EndpointHelper.resolveEndpointUriPropertyPlaceholders(this, uri);
             return NormalizedUri.newNormalizedUri(uri, false);
+        } catch (ResolveEndpointFailedException e) {
+            throw e;
         } catch (Exception e) {
-            if (e instanceof ResolveEndpointFailedException) {
-                throw e;
-            }
             throw new ResolveEndpointFailedException(uri, e);
         }
     }


[camel] 04/09: (chores) camel-bean: use standard check for exception type in catch blocks

Posted by or...@apache.org.
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

commit 99c4ba1c52958350851c53a30379e2e11b6bf4ca
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Oct 18 16:50:12 2022 +0200

    (chores) camel-bean: use standard check for exception type in catch blocks
---
 .../src/main/java/org/apache/camel/language/bean/BeanExpression.java | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/components/camel-bean/src/main/java/org/apache/camel/language/bean/BeanExpression.java b/components/camel-bean/src/main/java/org/apache/camel/language/bean/BeanExpression.java
index 21a27d7b882..4ed09b828d7 100644
--- a/components/camel-bean/src/main/java/org/apache/camel/language/bean/BeanExpression.java
+++ b/components/camel-bean/src/main/java/org/apache/camel/language/bean/BeanExpression.java
@@ -201,10 +201,9 @@ public class BeanExpression implements Expression, Predicate {
                 // regular non ognl invocation
                 return invokeBean(beanHolder, beanName, method, exchange);
             }
+        } catch (RuntimeBeanExpressionException e) {
+            throw e;
         } catch (Exception e) {
-            if (e instanceof RuntimeBeanExpressionException) {
-                throw (RuntimeBeanExpressionException) e;
-            }
             throw new RuntimeBeanExpressionException(exchange, getBeanName(exchange, beanName, beanHolder), method, e);
         }
     }