You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/01/09 20:33:51 UTC

[1/3] camel git commit: CAMEL-10684: camel-catalog - Simple validator should provide location index of the error

Repository: camel
Updated Branches:
  refs/heads/camel-2.18.x 28c066c23 -> 37c6375b7
  refs/heads/master 43b9583b8 -> 318964b7b


CAMEL-10684: camel-catalog - Simple validator should provide location index of the error


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/837b64f1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/837b64f1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/837b64f1

Branch: refs/heads/master
Commit: 837b64f15535ffe66fd2f40338d92e3b328c4a36
Parents: 43b9583
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Jan 9 21:26:51 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Jan 9 21:26:51 2017 +0100

----------------------------------------------------------------------
 .../camel/catalog/DefaultCamelCatalog.java      | 26 ++++++++++++++++++--
 .../camel/catalog/SimpleValidationResult.java   |  9 +++++++
 .../apache/camel/catalog/CamelCatalogTest.java  |  2 ++
 3 files changed, 35 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/837b64f1/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
index fcf74be..8089281 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
@@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
@@ -1827,6 +1828,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
         }
 
         if (clazz != null && instance != null) {
+            Throwable cause = null;
             try {
                 if (predicate) {
                     instance.getClass().getMethod("createPredicate", String.class).invoke(instance, simple);
@@ -1834,9 +1836,29 @@ public class DefaultCamelCatalog implements CamelCatalog {
                     instance.getClass().getMethod("createExpression", String.class).invoke(instance, simple);
                 }
             } catch (InvocationTargetException e) {
-                answer.setError(e.getTargetException().getMessage());
+                cause = e.getTargetException();
             } catch (Exception e) {
-                answer.setError(e.getMessage());
+                cause = e;
+            }
+
+            if (cause != null) {
+                answer.setError(cause.getMessage());
+
+                // is it simple parser exception then we can grab the index where the problem is
+                if (cause.getClass().getName().equals("org.apache.camel.language.simple.types.SimpleIllegalSyntaxException")
+                    || cause.getClass().getName().equals("org.apache.camel.language.simple.types.SimpleParserException")) {
+                    try {
+                        // we need to grab the index field from those simple parser exceptions
+                        Method method = cause.getClass().getMethod("getIndex");
+                        Object result = method.invoke(cause);
+                        if (result != null) {
+                            int index = (int) result;
+                            answer.setIndex(index);
+                        }
+                    } catch (Throwable i) {
+                        // ignore
+                    }
+                }
             }
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/837b64f1/platforms/catalog/src/main/java/org/apache/camel/catalog/SimpleValidationResult.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/SimpleValidationResult.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/SimpleValidationResult.java
index cd11ef0..87c846e 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/SimpleValidationResult.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/SimpleValidationResult.java
@@ -22,6 +22,7 @@ public class SimpleValidationResult implements Serializable {
 
     private final String simple;
     private String error;
+    private int index;
 
     public SimpleValidationResult(String simple) {
         this.simple = simple;
@@ -42,4 +43,12 @@ public class SimpleValidationResult implements Serializable {
     public String getError() {
         return error;
     }
+
+    public int getIndex() {
+        return index;
+    }
+
+    public void setIndex(int index) {
+        this.index = index;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/837b64f1/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java b/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
index 6380941..cc6c339 100644
--- a/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
+++ b/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
@@ -802,6 +802,7 @@ public class CamelCatalogTest {
         assertEquals("${body", result.getSimple());
         LOG.info(result.getError());
         assertTrue(result.getError().startsWith("expected symbol functionEnd but was eol at location 5"));
+        assertEquals(5, result.getIndex());
     }
 
     @Test
@@ -815,6 +816,7 @@ public class CamelCatalogTest {
         assertEquals("${body} > ${header.size", result.getSimple());
         LOG.info(result.getError());
         assertTrue(result.getError().startsWith("expected symbol functionEnd but was eol at location 22"));
+        assertEquals(22, result.getIndex());
     }
 
     @Test


[2/3] camel git commit: Regen docs

Posted by da...@apache.org.
Regen docs


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/318964b7
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/318964b7
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/318964b7

Branch: refs/heads/master
Commit: 318964b7b50804c3b6b0a74ece49d575141571a2
Parents: 837b64f
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Jan 9 21:32:02 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Jan 9 21:32:02 2017 +0100

----------------------------------------------------------------------
 components/camel-amqp/src/main/docs/amqp-component.adoc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/318964b7/components/camel-amqp/src/main/docs/amqp-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-amqp/src/main/docs/amqp-component.adoc b/components/camel-amqp/src/main/docs/amqp-component.adoc
index e2d8dc1..7496e05 100644
--- a/components/camel-amqp/src/main/docs/amqp-component.adoc
+++ b/components/camel-amqp/src/main/docs/amqp-component.adoc
@@ -135,7 +135,7 @@ The AMQP component supports 74 options which are listed below.
 
 
 // endpoint options: START
-The AMQP component supports 85 endpoint options which are listed below:
+The AMQP component supports 86 endpoint options which are listed below:
 
 {% raw %}
 [width="100%",cols="2,1,1m,1m,5",options="header"]
@@ -189,6 +189,7 @@ The AMQP component supports 85 endpoint options which are listed below:
 | includeSentJMSMessageID | producer (advanced) | false | boolean | Only applicable when sending to JMS destination using InOnly (eg fire and forget). Enabling this option will enrich the Camel Exchange with the actual JMSMessageID that was used by the JMS client when the message was sent to the JMS destination.
 | replyToCacheLevelName | producer (advanced) |  | String | Sets the cache level by name for the reply consumer when doing request/reply over JMS. This option only applies when using fixed reply queues (not temporary). Camel will by default use: CACHE_CONSUMER for exclusive or shared w/ replyToSelectorName. And CACHE_SESSION for shared without replyToSelectorName. Some JMS brokers such as IBM WebSphere may require to set the replyToCacheLevelName=CACHE_NONE to work. Note: If using temporary queues then CACHE_NONE is not allowed and you must use a higher value such as CACHE_CONSUMER or CACHE_SESSION.
 | replyToDestinationSelectorName | producer (advanced) |  | String | Sets the JMS Selector using the fixed name to be used so you can filter out your own replies from the others when using a shared queue (that is if you are not using a temporary reply queue).
+| allowSerializedHeaders | advanced | false | boolean | Controls whether or not to include serialized headers. Applies only when transferExchange is true. This requires that the objects are serializable. Camel will exclude any non-serializable objects and log it at WARN level.
 | asyncStartListener | advanced | false | boolean | Whether to startup the JmsConsumer message listener asynchronously when starting a route. For example if a JmsConsumer cannot get a connection to a remote JMS broker then it may block while retrying and/or failover. This will cause Camel to block while starting routes. By setting this option to true you will let routes startup while the JmsConsumer connects to the JMS broker using a dedicated thread in asynchronous mode. If this option is used then beware that if the connection could not be established then an exception is logged at WARN level and the consumer will not be able to receive messages; You can then restart the route to retry.
 | asyncStopListener | advanced | false | boolean | Whether to stop the JmsConsumer message listener asynchronously when stopping a route.
 | destinationResolver | advanced |  | DestinationResolver | A pluggable org.springframework.jms.support.destination.DestinationResolver that allows you to use your own resolver (for example to lookup the real destination in a JNDI registry).


[3/3] camel git commit: CAMEL-10684: camel-catalog - Simple validator should provide location index of the error

Posted by da...@apache.org.
CAMEL-10684: camel-catalog - Simple validator should provide location index of the error


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/37c6375b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/37c6375b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/37c6375b

Branch: refs/heads/camel-2.18.x
Commit: 37c6375b7e8d1a8f8cafc9898ccf2f3787eef6ae
Parents: 28c066c
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Jan 9 21:26:51 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Jan 9 21:33:22 2017 +0100

----------------------------------------------------------------------
 .../camel/catalog/DefaultCamelCatalog.java      | 26 ++++++++++++++++++--
 .../camel/catalog/SimpleValidationResult.java   |  9 +++++++
 .../apache/camel/catalog/CamelCatalogTest.java  |  2 ++
 3 files changed, 35 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/37c6375b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
index 74b4b41..688c546 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
@@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
@@ -1683,6 +1684,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
         }
 
         if (clazz != null && instance != null) {
+            Throwable cause = null;
             try {
                 if (predicate) {
                     instance.getClass().getMethod("createPredicate", String.class).invoke(instance, simple);
@@ -1690,9 +1692,29 @@ public class DefaultCamelCatalog implements CamelCatalog {
                     instance.getClass().getMethod("createExpression", String.class).invoke(instance, simple);
                 }
             } catch (InvocationTargetException e) {
-                answer.setError(e.getTargetException().getMessage());
+                cause = e.getTargetException();
             } catch (Exception e) {
-                answer.setError(e.getMessage());
+                cause = e;
+            }
+
+            if (cause != null) {
+                answer.setError(cause.getMessage());
+
+                // is it simple parser exception then we can grab the index where the problem is
+                if (cause.getClass().getName().equals("org.apache.camel.language.simple.types.SimpleIllegalSyntaxException")
+                    || cause.getClass().getName().equals("org.apache.camel.language.simple.types.SimpleParserException")) {
+                    try {
+                        // we need to grab the index field from those simple parser exceptions
+                        Method method = cause.getClass().getMethod("getIndex");
+                        Object result = method.invoke(cause);
+                        if (result != null) {
+                            int index = (int) result;
+                            answer.setIndex(index);
+                        }
+                    } catch (Throwable i) {
+                        // ignore
+                    }
+                }
             }
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/37c6375b/platforms/catalog/src/main/java/org/apache/camel/catalog/SimpleValidationResult.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/SimpleValidationResult.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/SimpleValidationResult.java
index cd11ef0..87c846e 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/SimpleValidationResult.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/SimpleValidationResult.java
@@ -22,6 +22,7 @@ public class SimpleValidationResult implements Serializable {
 
     private final String simple;
     private String error;
+    private int index;
 
     public SimpleValidationResult(String simple) {
         this.simple = simple;
@@ -42,4 +43,12 @@ public class SimpleValidationResult implements Serializable {
     public String getError() {
         return error;
     }
+
+    public int getIndex() {
+        return index;
+    }
+
+    public void setIndex(int index) {
+        this.index = index;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/37c6375b/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java b/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
index 6380941..cc6c339 100644
--- a/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
+++ b/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
@@ -802,6 +802,7 @@ public class CamelCatalogTest {
         assertEquals("${body", result.getSimple());
         LOG.info(result.getError());
         assertTrue(result.getError().startsWith("expected symbol functionEnd but was eol at location 5"));
+        assertEquals(5, result.getIndex());
     }
 
     @Test
@@ -815,6 +816,7 @@ public class CamelCatalogTest {
         assertEquals("${body} > ${header.size", result.getSimple());
         LOG.info(result.getError());
         assertTrue(result.getError().startsWith("expected symbol functionEnd but was eol at location 22"));
+        assertEquals(22, result.getIndex());
     }
 
     @Test