This is an automated email from the ASF dual-hosted git repository.
davsclaus 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 4dbad6262a3 jq: don't load additional functions for provided Scope
instance (#7944)
4dbad6262a3 is described below
commit 4dbad6262a3e850530a6d191bcc702f8fc0e81df
Author: Luca Burgazzoli <[email protected]>
AuthorDate: Thu Jun 30 11:50:54 2022 +0200
jq: don't load additional functions for provided Scope instance (#7944)
---
.../java/org/apache/camel/language/jq/JqExpression.java | 8 --------
.../org/apache/camel/language/jq/JqExpressionTest.java | 16 ++++++----------
2 files changed, 6 insertions(+), 18 deletions(-)
diff --git
a/components/camel-jq/src/main/java/org/apache/camel/language/jq/JqExpression.java
b/components/camel-jq/src/main/java/org/apache/camel/language/jq/JqExpression.java
index 7512312ec85..deaf5e200b5 100644
---
a/components/camel-jq/src/main/java/org/apache/camel/language/jq/JqExpression.java
+++
b/components/camel-jq/src/main/java/org/apache/camel/language/jq/JqExpression.java
@@ -76,14 +76,6 @@ public class JqExpression extends ExpressionAdapter
implements ExpressionResultT
this.scope = Scope.newEmptyScope();
JqFunctions.load(camelContext, scope);
- JqFunctions.loadLocal(scope);
- } else {
- // if no scope is explicit set or found in the registry, then a
local
- // child scope is created and local functions are loaded. Local
- // functions do not leak into the global scope as they are local to
- // the child scope.
- this.scope = Scope.newChildScope(scope);
-
JqFunctions.loadLocal(scope);
}
diff --git
a/components/camel-jq/src/test/java/org/apache/camel/language/jq/JqExpressionTest.java
b/components/camel-jq/src/test/java/org/apache/camel/language/jq/JqExpressionTest.java
index 04996682291..ae61fc93bdb 100644
---
a/components/camel-jq/src/test/java/org/apache/camel/language/jq/JqExpressionTest.java
+++
b/components/camel-jq/src/test/java/org/apache/camel/language/jq/JqExpressionTest.java
@@ -256,11 +256,9 @@ public class JqExpressionTest {
expression.setScope(root);
expression.init(context);
- assertThat(expression.getScope()).isNotSameAs(root);
- assertThat(expression.getScope().getParentScope()).isSameAs(root);
-
-
assertThat(root.getLocalFunctions()).doesNotContainKeys("header/1", "header/2");
-
assertThat(expression.getScope().getLocalFunctions()).containsKeys("header/1",
"header/2");
+ assertThat(expression.getScope()).isSameAs(root);
+ assertThat(expression.getScope().getParentScope()).isNull();
+
assertThat(expression.getScope().getLocalFunctions()).doesNotContainKeys("header/1",
"header/2");
}
}
@@ -273,11 +271,9 @@ public class JqExpressionTest {
JqExpression expression = new JqExpression(".foo");
expression.init(context);
- assertThat(expression.getScope()).isNotSameAs(root);
- assertThat(expression.getScope().getParentScope()).isSameAs(root);
-
-
assertThat(root.getLocalFunctions()).doesNotContainKeys("header/1", "header/2");
-
assertThat(expression.getScope().getLocalFunctions()).containsKeys("header/1",
"header/2");
+ assertThat(expression.getScope()).isSameAs(root);
+ assertThat(expression.getScope().getParentScope()).isNull();
+
assertThat(expression.getScope().getLocalFunctions()).doesNotContainKeys("header/1",
"header/2");
}
}
}