You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by np...@apache.org on 2021/09/15 17:44:28 UTC
[sling-org-apache-sling-pipes] 02/04: SLING-10419 add context in
log (and test)
This is an automated email from the ASF dual-hosted git repository.
npeltier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-pipes.git
commit f9f8289fb4225b933b9af7dc20b6fb9ac1c19318
Author: Nicolas Peltier <np...@apache.org>
AuthorDate: Wed Sep 15 15:35:54 2021 +0200
SLING-10419 add context in log (and test)
---
src/main/java/org/apache/sling/pipes/BasePipe.java | 4 ++--
src/test/java/org/apache/sling/pipes/PipeBindingsTest.java | 12 ++++++++++++
src/test/resources/simplelogger.properties | 2 +-
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/apache/sling/pipes/BasePipe.java b/src/main/java/org/apache/sling/pipes/BasePipe.java
index 05a616c..09374c8 100644
--- a/src/main/java/org/apache/sling/pipes/BasePipe.java
+++ b/src/main/java/org/apache/sling/pipes/BasePipe.java
@@ -336,11 +336,11 @@ public class BasePipe implements Pipe {
if (StringUtils.isBlank(path)){
Resource input = getPreviousResource();
if (input != null){
- path = resource.getPath();
+ path = input.getPath();
}
}
bindings.setCurrentError(path);
- logger.error("error with pipe execution from {}", path, e);
+ logger.error("error with pipe execution from {}, running on resource {}", resource.getPath(), path, e);
}
return EMPTY_ITERATOR;
}
diff --git a/src/test/java/org/apache/sling/pipes/PipeBindingsTest.java b/src/test/java/org/apache/sling/pipes/PipeBindingsTest.java
index f6529ef..c669ed8 100644
--- a/src/test/java/org/apache/sling/pipes/PipeBindingsTest.java
+++ b/src/test/java/org/apache/sling/pipes/PipeBindingsTest.java
@@ -144,4 +144,16 @@ public class PipeBindingsTest extends AbstractPipeTest {
assertTrue(result.size() > 0);
assertEquals("/content/fruits/apple", result.currentPathSet.iterator().next());
}
+
+ @Test
+ public void testContextualError() throws InvocationTargetException, IllegalAccessException {
+ ExecutionResult first = execute("json {'one':{'foo':'bar'},'two':{'another':'one'},'three':{'foo':'longer'}} | " +
+ "mkdir /content/context/${one.key} | " +
+ "write ${one.value.foo?'foo':'blah'}=one.value.foo");
+ //the following should fail for /content/context/two
+ ExecutionResult result = execute("echo /content/context " +
+ "| children sling:Folder @ name child " +
+ "| write foo=${child.foo?child.foo:nonexistingFunction(nonexistingVariable)}");
+ assertEquals(2, result.size());
+ }
}
\ No newline at end of file
diff --git a/src/test/resources/simplelogger.properties b/src/test/resources/simplelogger.properties
index 16018c4..0217e08 100644
--- a/src/test/resources/simplelogger.properties
+++ b/src/test/resources/simplelogger.properties
@@ -15,7 +15,7 @@
# limitations under the License.
org.slf4j.simpleLogger.logFile=System.out
-org.slf4j.simpleLogger.defaultLogLevel=off
+org.slf4j.simpleLogger.defaultLogLevel=debug
org.slf4j.simpleLogger.log.org.apache.jackrabbit.oak.plugins.index.IndexUpdate=warn
org.slf4j.simpleLogger.log.org.apache.sling.scripting.core.impl.ScriptEngineManagerFactory=warn
org.slf4j.simpleLogger.log.org.apache.sling.resourceresolver.impl.mapping.MapEntries=warn