You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/04/12 06:16:32 UTC
git commit: CAMEL-7359 fixed the same issue with headerAs
Repository: camel
Updated Branches:
refs/heads/master e6fbbf046 -> 9cb09d14d
CAMEL-7359 fixed the same issue with headerAs
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9cb09d14
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9cb09d14
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9cb09d14
Branch: refs/heads/master
Commit: 9cb09d14d48b8b1d206eac3f4981565cef797ca8
Parents: e6fbbf0
Author: Willem Jiang <wi...@gmail.com>
Authored: Sat Apr 12 12:15:49 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Sat Apr 12 12:15:49 2014 +0800
----------------------------------------------------------------------
.../camel/language/simple/ast/SimpleFunctionExpression.java | 3 ++-
.../java/org/apache/camel/language/simple/SimpleTest.java | 7 +++++++
2 files changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/9cb09d14/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java b/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
index 32a22b2..4eedcba 100644
--- a/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
+++ b/camel-core/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
@@ -238,7 +238,8 @@ public class SimpleFunctionExpression extends LiteralExpression {
String key = ObjectHelper.before(keyAndType, ",");
String type = ObjectHelper.after(keyAndType, ",");
- if (ObjectHelper.isEmpty(key) || ObjectHelper.isEmpty(type)) {
+ remainder = ObjectHelper.after(remainder, ")");
+ if (ObjectHelper.isEmpty(key) || ObjectHelper.isEmpty(type) || ObjectHelper.isNotEmpty(remainder)) {
throw new SimpleParserException("Valid syntax: ${headerAs(key, type)} was: " + function, token.getIndex());
}
key = StringHelper.removeQuotes(key);
http://git-wip-us.apache.org/repos/asf/camel/blob/9cb09d14/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
index 88c00c1..ac727e9 100644
--- a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
+++ b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
@@ -582,6 +582,13 @@ public class SimpleTest extends LanguageTestSupport {
} catch (ExpressionIllegalSyntaxException e) {
assertTrue(e.getMessage().startsWith("Valid syntax: ${headerAs(key, type)} was: headerAs(unknown String)"));
}
+
+ try {
+ assertExpression("${headerAs(fool,String).test}", null);
+ fail("Should have thrown an exception");
+ } catch (ExpressionIllegalSyntaxException e) {
+ assertTrue(e.getMessage().startsWith("Valid syntax: ${headerAs(key, type)} was: headerAs(fool,String).test"));
+ }
try {
assertExpression("${headerAs(bar,XXX)}", 123);