This is an automated email from the ASF dual-hosted git repository. daim pushed a commit to branch OAK-11549 in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit e1753bb73faa8758d1aeeac831383c3faec0f846 Author: Rishabh Kumar <[email protected]> AuthorDate: Wed Mar 5 20:08:11 2025 +0530 OAK-11549 : replaced Guava's Iterables.limit with oak-commons util --- .../jackrabbit/oak/plugins/index/property/jmx/PropertyIndexStats.java | 2 +- .../java/org/apache/jackrabbit/oak/security/user/PasswordHistory.java | 3 ++- .../oak/plugins/index/lucene/directory/IndexRootDirectory.java | 3 ++- .../groovy/org/apache/jackrabbit/oak/console/commands/CdCommand.groovy | 2 +- .../groovy/org/apache/jackrabbit/oak/console/commands/LsCommand.groovy | 3 ++- .../apache/jackrabbit/oak/composite/CompositeChildrenCountTest.java | 3 +-- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/jmx/PropertyIndexStats.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/jmx/PropertyIndexStats.java index 182ed26588..390fd2700c 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/jmx/PropertyIndexStats.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/jmx/PropertyIndexStats.java @@ -143,7 +143,7 @@ public class PropertyIndexStats extends AnnotatedStandardMBean implements Proper "[%d]. Estimated value count [%d]", maxValueCount, childNodeCount); } else { String[] values = IterableUtils.toArray( - Iterables.limit(data.getChildNodeNames(), maxValueCount), + IterableUtils.limit(data.getChildNodeNames(), maxValueCount), String.class ); diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/PasswordHistory.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/PasswordHistory.java index 66190c7358..848e341feb 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/PasswordHistory.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/PasswordHistory.java @@ -25,6 +25,7 @@ import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.commons.collections.IterableUtils; import org.apache.jackrabbit.oak.commons.collections.ListUtils; import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters; import org.apache.jackrabbit.oak.spi.security.user.UserConstants; @@ -119,7 +120,7 @@ final class PasswordHistory implements UserConstants { if (pwTree.exists()) { PropertyState pwHistoryProperty = pwTree.getProperty(UserConstants.REP_PWD_HISTORY); if (pwHistoryProperty != null) { - for (String historyPwHash : Iterables.limit(pwHistoryProperty.getValue(Type.STRINGS), maxSize)) { + for (String historyPwHash : IterableUtils.limit(pwHistoryProperty.getValue(Type.STRINGS), maxSize)) { if (PasswordUtil.isSame(historyPwHash, newPassword)) { throw new PasswordHistoryException("New password was found in password history."); } diff --git a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexRootDirectory.java b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexRootDirectory.java index b46a0e7795..00decf1cdd 100644 --- a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexRootDirectory.java +++ b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexRootDirectory.java @@ -37,6 +37,7 @@ import org.apache.jackrabbit.guava.common.hash.Hashing; import org.apache.commons.io.FileUtils; import org.apache.jackrabbit.oak.commons.IOUtils; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.IterableUtils; import org.apache.jackrabbit.oak.commons.collections.ListUtils; import org.apache.jackrabbit.oak.commons.conditions.Validate; import org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndex; @@ -194,7 +195,7 @@ public class IndexRootDirectory { List<String> result = new ArrayList<>(2); //Max 3 nodeNames including oak:index which is the immediate parent for any indexPath - for (String e : Iterables.limit(elements, 3)) { + for (String e : IterableUtils.limit(elements, 3)) { if ("oak:index".equals(e)) { continue; } diff --git a/oak-run/src/main/groovy/org/apache/jackrabbit/oak/console/commands/CdCommand.groovy b/oak-run/src/main/groovy/org/apache/jackrabbit/oak/console/commands/CdCommand.groovy index 4acb3dbac0..49df0c8d30 100644 --- a/oak-run/src/main/groovy/org/apache/jackrabbit/oak/console/commands/CdCommand.groovy +++ b/oak-run/src/main/groovy/org/apache/jackrabbit/oak/console/commands/CdCommand.groovy @@ -39,7 +39,7 @@ class CdCommand extends CommandSupport{ @Override SortedSet getCandidates() { SortedSet<String> names = new TreeSet<String>() - Iterables.limit(getSession().getWorkingNode().childNodeNames, 100).each { + IterableUtils.limit(getSession().getWorkingNode().childNodeNames, 100).each { names << it.replace(" ", "\\ ") } return names diff --git a/oak-run/src/main/groovy/org/apache/jackrabbit/oak/console/commands/LsCommand.groovy b/oak-run/src/main/groovy/org/apache/jackrabbit/oak/console/commands/LsCommand.groovy index baffaffc71..ed3b1b85c0 100644 --- a/oak-run/src/main/groovy/org/apache/jackrabbit/oak/console/commands/LsCommand.groovy +++ b/oak-run/src/main/groovy/org/apache/jackrabbit/oak/console/commands/LsCommand.groovy @@ -20,6 +20,7 @@ package org.apache.jackrabbit.oak.console.commands import org.apache.jackrabbit.guava.common.collect.Iterables import groovy.transform.CompileStatic +import org.apache.jackrabbit.oak.commons.collections.IterableUtils import org.apache.jackrabbit.oak.console.ConsoleSession import org.codehaus.groovy.tools.shell.CommandSupport import org.codehaus.groovy.tools.shell.Groovysh @@ -36,7 +37,7 @@ class LsCommand extends CommandSupport{ Object execute(List<String> args) { int limit = args ? args[0] as int : 50 def count = 0 - Iterables.limit(session.workingNode.childNodeNames, limit).each { + IterableUtils.limit(session.workingNode.childNodeNames, limit).each { count++ io.out.println(it) } diff --git a/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/CompositeChildrenCountTest.java b/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/CompositeChildrenCountTest.java index e2f5c51eb8..ce1b150641 100644 --- a/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/CompositeChildrenCountTest.java +++ b/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/CompositeChildrenCountTest.java @@ -42,7 +42,6 @@ import java.util.List; import java.util.Map; import static org.apache.jackrabbit.guava.common.collect.Iterables.cycle; -import static org.apache.jackrabbit.guava.common.collect.Iterables.limit; import static java.lang.Long.MAX_VALUE; import static java.util.Arrays.asList; @@ -221,7 +220,7 @@ public class CompositeChildrenCountTest { public Iterable<? extends ChildNodeEntry> getChildNodeEntries() { if (children == null) { Iterable<? extends ChildNodeEntry> childrenIterable = cycle(new MemoryChildNodeEntry("child", EMPTY_NODE)); - return asCountingIterable(limit(childrenIterable, childrenCount == MAX_VALUE ? 1000 : (int) childrenCount)); + return asCountingIterable(IterableUtils.limit(childrenIterable, childrenCount == MAX_VALUE ? 1000 : (int) childrenCount)); } else { return asCountingIterable(IterableUtils.transform(asList(children), input -> new MemoryChildNodeEntry(input, EMPTY_NODE))); }
