Skip to content

Commit

Permalink
fix(runner): allow each to loop over primitive and nested arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
sabberworm committed Nov 2, 2024
1 parent c08663c commit 214f936
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/com/swisscom/aem/tools/impl/hops/Each.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 214f936

Please sign in to comment.