From 214f936676915937872ac3eb7756f75cb60c3f8e Mon Sep 17 00:00:00 2001 From: Raphael Schweikert Date: Sat, 2 Nov 2024 19:31:48 +0100 Subject: [PATCH] fix(runner): allow each to loop over primitive and nested arrays --- src/main/java/com/swisscom/aem/tools/impl/hops/Each.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/swisscom/aem/tools/impl/hops/Each.java b/src/main/java/com/swisscom/aem/tools/impl/hops/Each.java index 1cc9744..fa523f9 100644 --- a/src/main/java/com/swisscom/aem/tools/impl/hops/Each.java +++ b/src/main/java/com/swisscom/aem/tools/impl/hops/Each.java @@ -5,6 +5,7 @@ import com.swisscom.aem.tools.jcrhopper.config.HopConfig; import com.swisscom.aem.tools.jcrhopper.context.HopContext; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import java.lang.reflect.Array; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; @@ -37,8 +38,8 @@ public void run(Config config, Node node, HopContext context) throws RepositoryE runWith(config, ((Iterator) items).next(), index++, node, context); } } else if (items.getClass().isArray()) { - for (Object item : (Object[]) items) { - runWith(config, item, index++, node, context); + for (index = 0; index < Array.getLength(items); index++) { + runWith(config, Array.get(items, index), index, node, context); } } else { runWith(config, items, index, node, context);