From 2ee3a628de40b673dadd32b111c52a8e89b1da42 Mon Sep 17 00:00:00 2001 From: Julian Reschke Date: Mon, 13 Jan 2025 10:57:15 +0100 Subject: [PATCH] OAK-11357: Extract StreamUtils from CollectionUtils --- .../external/impl/AbstractDynamicTest.java | 6 +- .../ExternalGroupPrincipalProviderTest.java | 3 +- .../principal/ExternalGroupPrincipalTest.java | 4 +- .../commons/collections/CollectionUtils.java | 27 --------- .../oak/commons/collections/StreamUtils.java | 59 +++++++++++++++++++ .../oak/commons/collections/package-info.java | 2 +- .../collections/CollectionUtilsTest.java | 9 --- .../commons/collections/StreamUtilsTest.java | 57 ++++++++++++++++++ .../plugins/commit/MergingNodeStateDiff.java | 6 +- .../index/property/PropertyIndexPlan.java | 3 +- .../oak/plugins/nodetype/TypeEditor.java | 5 +- .../oak/plugins/nodetype/TypePredicate.java | 7 ++- .../index/lucene/LucenePropertyIndex.java | 6 +- .../index/elastic/ElasticIndexDefinition.java | 8 +-- .../oak/composite/CompositeNodeStore.java | 3 +- .../oak/plugins/document/SplitOperations.java | 4 +- 16 files changed, 147 insertions(+), 62 deletions(-) create mode 100644 oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/StreamUtils.java create mode 100644 oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/StreamUtilsTest.java diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/AbstractDynamicTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/AbstractDynamicTest.java index 6094a9774e5..f1f7521e58f 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/AbstractDynamicTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/AbstractDynamicTest.java @@ -20,7 +20,7 @@ import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.UserManager; import org.apache.jackrabbit.oak.api.Root; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; +import org.apache.jackrabbit.oak.commons.collections.StreamUtils; import org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser; @@ -116,7 +116,7 @@ protected void sync(@NotNull ExternalIdentity externalIdentity, @NotNull SyncRes @NotNull static List getIds(@NotNull Iterator authorizables) { - return CollectionUtils.toStream(authorizables).map(authorizable -> { + return StreamUtils.toStream(authorizables).map(authorizable -> { try { return authorizable.getID(); } catch (RepositoryException repositoryException) { @@ -127,6 +127,6 @@ static List getIds(@NotNull Iterator authorizabl @NotNull static List getPrincipalNames(@NotNull Iterator groupPrincipals) { - return CollectionUtils.toStream(groupPrincipals).map(Principal::getName).collect(Collectors.toList()); + return StreamUtils.toStream(groupPrincipals).map(Principal::getName).collect(Collectors.toList()); } } \ No newline at end of file diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalProviderTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalProviderTest.java index f31f01b0978..dce8bfb0788 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalProviderTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalProviderTest.java @@ -28,6 +28,7 @@ import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; +import org.apache.jackrabbit.oak.commons.collections.StreamUtils; import org.apache.jackrabbit.oak.namepath.NamePathMapper; import org.apache.jackrabbit.oak.plugins.tree.TreeAware; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup; @@ -89,7 +90,7 @@ void sync(@NotNull ExternalUser externalUser) throws Exception { @NotNull Set getExpectedGroupPrincipals(@NotNull String userId) throws Exception { if (syncConfig.user().getMembershipNestingDepth() == 1) { - return CollectionUtils.toStream(idp.getUser(userId).getDeclaredGroups()).map(externalIdentityRef -> { + return StreamUtils.toStream(idp.getUser(userId).getDeclaredGroups()).map(externalIdentityRef -> { try { return new PrincipalImpl(idp.getIdentity(externalIdentityRef).getPrincipalName()); } catch (ExternalIdentityException e) { diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalTest.java index d22ea621267..8fb49c3b0c4 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalTest.java @@ -24,7 +24,7 @@ import org.apache.jackrabbit.oak.api.QueryEngine; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Type; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; +import org.apache.jackrabbit.oak.commons.collections.StreamUtils; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser; @@ -81,7 +81,7 @@ public void testNotIsMember() throws Exception { public void testIsMemberExternalGroup() throws Exception { GroupPrincipal principal = getGroupPrincipal(); - List exGroupPrincNames = CollectionUtils.toStream( + List exGroupPrincNames = StreamUtils.toStream( idp.listGroups()).map(ExternalIdentity::getPrincipalName).collect(Collectors.toList()); for (String principalName : exGroupPrincNames) { assertFalse(principal.isMember(new PrincipalImpl(principalName))); diff --git a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtils.java b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtils.java index 7be1a8c8bd8..67b47fbaed9 100644 --- a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtils.java +++ b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtils.java @@ -40,7 +40,6 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; -import java.util.stream.StreamSupport; import org.jetbrains.annotations.NotNull; @@ -519,32 +518,6 @@ public static Iterable toIterable(@NotNull final Iterator iterator) { }; } - /** - * Generates a (non-parallel) {@linkplain Stream} for the {@linkplain Iterable} - * @param iterable iterable to convert - * @return the stream - */ - @NotNull - public static Stream toStream(@NotNull Iterable iterable) { - Objects.requireNonNull(iterable); - return StreamSupport.stream(iterable.spliterator(), false); - } - - /** - * Generates a (non-parallel) {@linkplain Stream} for the - * {@linkplain Iterable} - *

- * This method is not thread-safe - * - * @param iterator - * iterator to convert - * @return the stream (representing the remaining elements in the iterator) - */ - @NotNull - public static Stream toStream(@NotNull Iterator iterator) { - return StreamSupport.stream(toIterable(iterator).spliterator(), false); - } - /** * Ensure the capacity of a map or set given the expected number of elements. * diff --git a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/StreamUtils.java b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/StreamUtils.java new file mode 100644 index 00000000000..8bdfdec93e4 --- /dev/null +++ b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/StreamUtils.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.jackrabbit.oak.commons.collections; + +import org.jetbrains.annotations.NotNull; + +import java.util.Iterator; +import java.util.Objects; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; + +public class StreamUtils { + + private StreamUtils() { + // no instances for you + } + + /** + * Generates a (non-parallel) {@linkplain Stream} for the {@linkplain Iterable} + * @param iterable iterable to convert + * @return the stream + */ + @NotNull + public static Stream toStream(@NotNull Iterable iterable) { + Objects.requireNonNull(iterable); + return StreamSupport.stream(iterable.spliterator(), false); + } + + /** + * Generates a (non-parallel) {@linkplain Stream} for the + * {@linkplain Iterable} + *

+ * This method is not thread-safe + * + * @param iterator + * iterator to convert + * @return the stream (representing the remaining elements in the iterator) + */ + @NotNull + public static Stream toStream(@NotNull Iterator iterator) { + return StreamSupport.stream(CollectionUtils.toIterable(iterator).spliterator(), false); + } +} diff --git a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/package-info.java b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/package-info.java index 11a3fa317b3..95dfb8621ef 100644 --- a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/package-info.java +++ b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/package-info.java @@ -21,7 +21,7 @@ * Utilities for Java collections and streams. */ @Internal(since = "1.0.0") -@Version("1.2.0") +@Version("2.0.0") package org.apache.jackrabbit.oak.commons.collections; import org.apache.jackrabbit.oak.commons.annotations.Internal; import org.osgi.annotation.versioning.Version; diff --git a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtilsTest.java b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtilsTest.java index 2f3168d3c09..03ae1372679 100644 --- a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtilsTest.java +++ b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtilsTest.java @@ -495,15 +495,6 @@ public void iteratorToIIteratable() { } } - @Test - public void iteratorToStream() { - List input = List.of("a", "b", "c"); - Iterator iterator = input.iterator(); - Stream stream = CollectionUtils.toStream(iterator); - List result = stream.collect(Collectors.toList()); - Assert.assertEquals(input.toString(), result.toString()); - } - @Test public void testFromProperties() { final Properties properties = new Properties(); diff --git a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/StreamUtilsTest.java b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/StreamUtilsTest.java new file mode 100644 index 00000000000..12843718f28 --- /dev/null +++ b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/StreamUtilsTest.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.jackrabbit.oak.commons.collections; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class StreamUtilsTest { + + @Test + public void iteratorToStream() { + List input = List.of("a", "b", "c"); + Iterator iterator = input.iterator(); + Stream stream = StreamUtils.toStream(iterator); + List result = stream.collect(Collectors.toList()); + Assert.assertEquals(input.toString(), result.toString()); + } + + @Test(expected = NullPointerException.class) + public void iteratorToStreamNull() { + StreamUtils.toStream((Iterator)null); + } + + @Test + public void iterableToStream() { + List input = List.of("a", "b", "c"); + Stream stream = StreamUtils.toStream(input); + List result = stream.collect(Collectors.toList()); + Assert.assertEquals(input.toString(), result.toString()); + } + + @Test(expected = NullPointerException.class) + public void iterableStreamNull() { + StreamUtils.toStream((Iterable)null); + } +} \ No newline at end of file diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java index 7dde9ab9d11..b842d3eb9d2 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java @@ -37,7 +37,7 @@ import java.util.stream.Stream; import org.apache.jackrabbit.oak.api.PropertyState; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; +import org.apache.jackrabbit.oak.commons.collections.StreamUtils; import org.apache.jackrabbit.oak.json.JsopDiff; import org.apache.jackrabbit.oak.plugins.memory.PropertyBuilder; import org.apache.jackrabbit.oak.plugins.tree.TreeConstants; @@ -134,8 +134,8 @@ private void resolveConflict(ConflictType conflictType, NodeState conflictInfo) NodeState oursNS = conflictInfo.getChildNode(OURS); NodeState baseNS = conflictInfo.getChildNode(BASE); - Set candidates = Stream.concat(CollectionUtils.toStream(oursNS.getChildNodeNames()), - CollectionUtils.toStream(baseNS.getChildNodeNames())).collect(toSet()); + Set candidates = Stream.concat(StreamUtils.toStream(oursNS.getChildNodeNames()), + StreamUtils.toStream(baseNS.getChildNodeNames())).collect(toSet()); for (String name : candidates) { NodeState ours = oursNS.getChildNode(name); NodeState base = baseNS.getChildNode(name); diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexPlan.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexPlan.java index 849c281925d..b38195616db 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexPlan.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexPlan.java @@ -27,6 +27,7 @@ import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; +import org.apache.jackrabbit.oak.commons.collections.StreamUtils; import org.apache.jackrabbit.oak.plugins.index.IndexConstants; import org.apache.jackrabbit.oak.plugins.index.IndexUtils; import org.apache.jackrabbit.oak.plugins.index.cursor.Cursors; @@ -108,7 +109,7 @@ public class PropertyIndexPlan { this.matchesAllTypes = !definition.hasProperty(DECLARING_NODE_TYPES); this.deprecated = definition.getBoolean(IndexConstants.INDEX_DEPRECATED); this.matchesNodeTypes = - matchesAllTypes || CollectionUtils.toStream(types).anyMatch(filter.getSupertypes()::contains); + matchesAllTypes || StreamUtils.toStream(types).anyMatch(filter.getSupertypes()::contains); ValuePattern valuePattern = new ValuePattern(definition); diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java index 4b929bf7b8f..199524d7550 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditor.java @@ -50,6 +50,7 @@ import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; +import org.apache.jackrabbit.oak.commons.collections.StreamUtils; import org.apache.jackrabbit.oak.namepath.NamePathMapper; import org.apache.jackrabbit.oak.plugins.value.jcr.PartialValueFactory; import org.apache.jackrabbit.oak.spi.commit.DefaultEditor; @@ -176,7 +177,7 @@ public static TypeEditor create(@NotNull ConstraintViolationCallback callback, S this.checkThisNode = typesToCheck == null || typesToCheck.contains(primary) - || CollectionUtils.toStream(mixins).anyMatch(typesToCheck::contains); + || StreamUtils.toStream(mixins).anyMatch(typesToCheck::contains); this.parent = null; this.nodeName = null; this.types = requireNonNull(types); @@ -196,7 +197,7 @@ private TypeEditor( this.checkThisNode = typesToCheck == null || typesToCheck.contains(primary) - || CollectionUtils.toStream(mixins).anyMatch(typesToCheck::contains); + || StreamUtils.toStream(mixins).anyMatch(typesToCheck::contains); this.parent = requireNonNull(parent); this.nodeName = requireNonNull(name); this.types = parent.types; diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypePredicate.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypePredicate.java index 68f5e994b62..66a858715cd 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypePredicate.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypePredicate.java @@ -25,6 +25,7 @@ import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; +import org.apache.jackrabbit.oak.commons.collections.StreamUtils; import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.apache.jackrabbit.oak.plugins.tree.TreeUtil; @@ -161,7 +162,7 @@ public boolean test(String primary, Set mixins) { if (primaryTypes != null && primaryTypes.contains(primary)) { return true; } - if (mixinTypes != null && CollectionUtils.toStream(mixins).anyMatch(mixinTypes::contains)) { + if (mixinTypes != null && StreamUtils.toStream(mixins).anyMatch(mixinTypes::contains)) { return true; } return false; @@ -175,7 +176,7 @@ public boolean test(@Nullable Tree input) { return true; } if (mixinTypes != null - && CollectionUtils.toStream(TreeUtil.getNames(input, JCR_MIXINTYPES)).anyMatch(mixinTypes::contains)) { + && StreamUtils.toStream(TreeUtil.getNames(input, JCR_MIXINTYPES)).anyMatch(mixinTypes::contains)) { return true; } } @@ -193,7 +194,7 @@ public boolean test(@Nullable NodeState input) { return true; } if (mixinTypes != null - && CollectionUtils.toStream(input.getNames(JCR_MIXINTYPES)).anyMatch(mixinTypes::contains)) { + && StreamUtils.toStream(input.getNames(JCR_MIXINTYPES)).anyMatch(mixinTypes::contains)) { return true; } } diff --git a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java index 093852c4f66..63b5f99d3a9 100644 --- a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java +++ b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java @@ -45,7 +45,7 @@ import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.commons.PerfLogger; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; +import org.apache.jackrabbit.oak.commons.collections.StreamUtils; import org.apache.jackrabbit.oak.commons.conditions.Validate; import org.apache.jackrabbit.oak.commons.properties.SystemPropertySupplier; import org.apache.jackrabbit.oak.plugins.index.lucene.util.fv.SimSearchUtils; @@ -1088,7 +1088,7 @@ private static void addNonFullTextConstraints(List qs, // deduced if (planResult.isPathTransformed()) { String parentPathSegment = planResult.getParentPathSegment(); - if (!CollectionUtils.toStream(PathUtils.elements(parentPathSegment)).anyMatch("*"::equals)) { + if (!StreamUtils.toStream(PathUtils.elements(parentPathSegment)).anyMatch("*"::equals)) { qs.add(new TermQuery(newPathTerm(path + parentPathSegment))); } } else { @@ -1106,7 +1106,7 @@ private static void addNonFullTextConstraints(List qs, // deduced if (planResult.isPathTransformed()) { String parentPathSegment = planResult.getParentPathSegment(); - if (!CollectionUtils.toStream(PathUtils.elements(parentPathSegment)).anyMatch("*"::equals)) { + if (!StreamUtils.toStream(PathUtils.elements(parentPathSegment)).anyMatch("*"::equals)) { qs.add(new TermQuery(newPathTerm(getParentPath(path) + parentPathSegment))); } } else { diff --git a/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDefinition.java b/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDefinition.java index edc912867b4..1840e755eff 100644 --- a/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDefinition.java +++ b/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDefinition.java @@ -30,7 +30,7 @@ import java.util.stream.Stream; import org.apache.jackrabbit.oak.api.Type; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; +import org.apache.jackrabbit.oak.commons.collections.StreamUtils; import org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants; import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition; import org.apache.jackrabbit.oak.plugins.index.search.PropertyDefinition; @@ -223,7 +223,7 @@ public ElasticIndexDefinition(NodeState root, NodeState defn, String indexPath, this.propertiesByName = getDefinedRules() .stream() - .flatMap(rule -> Stream.concat(CollectionUtils.toStream(rule.getProperties()), + .flatMap(rule -> Stream.concat(StreamUtils.toStream(rule.getProperties()), rule.getFunctionRestrictions().stream())) .filter(pd -> pd.index) // keep only properties that can be indexed .collect(Collectors.groupingBy(pd -> { @@ -433,12 +433,12 @@ public InferenceDefinition() { } */ public InferenceDefinition(NodeState inferenceNode) { if (inferenceNode.hasChildNode("properties")) { - this.properties = CollectionUtils.toStream(inferenceNode.getChildNode("properties").getChildNodeEntries()) + this.properties = StreamUtils.toStream(inferenceNode.getChildNode("properties").getChildNodeEntries()) .map(cne -> new Property(cne.getName(), cne.getNodeState())) .collect(Collectors.toList()); } if (inferenceNode.hasChildNode("queries")) { - this.queries = CollectionUtils.toStream(inferenceNode.getChildNode("queries").getChildNodeEntries()) + this.queries = StreamUtils.toStream(inferenceNode.getChildNode("queries").getChildNodeEntries()) .map(cne -> new Query(cne.getName(), cne.getNodeState())) .collect(Collectors.toList()); } diff --git a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeNodeStore.java b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeNodeStore.java index c6533bdb1c0..56246a2cd3a 100644 --- a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeNodeStore.java +++ b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeNodeStore.java @@ -21,6 +21,7 @@ import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; +import org.apache.jackrabbit.oak.commons.collections.StreamUtils; import org.apache.jackrabbit.oak.composite.checks.NodeStoreChecks; import org.apache.jackrabbit.oak.spi.commit.ChangeDispatcher; import org.apache.jackrabbit.oak.spi.commit.CommitHook; @@ -318,7 +319,7 @@ private String getPartialCheckpointName(MountedNodeStore nodeStore, String globa } private static boolean checkpointExists(NodeStore nodeStore, String checkpoint) { - return CollectionUtils.toStream(nodeStore.checkpoints()).anyMatch(x -> Objects.equals(x, checkpoint)); + return StreamUtils.toStream(nodeStore.checkpoints()).anyMatch(x -> Objects.equals(x, checkpoint)); } private String checkpointDebugInfo() { diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/SplitOperations.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/SplitOperations.java index 1bea179c40d..e5457b8a478 100644 --- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/SplitOperations.java +++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/SplitOperations.java @@ -33,7 +33,7 @@ import java.util.function.Supplier; import java.util.stream.Collectors; -import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; +import org.apache.jackrabbit.oak.commons.collections.StreamUtils; import org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore; import org.apache.jackrabbit.oak.plugins.document.util.Utils; import org.jetbrains.annotations.NotNull; @@ -227,7 +227,7 @@ private void populateSplitRevs() { } private boolean hasBinaryPropertyForSplit(Iterable values) { - return doc.hasBinary() && CollectionUtils.toStream(values).map(binarySize).anyMatch(BINARY_FOR_SPLIT_THRESHOLD); + return doc.hasBinary() && StreamUtils.toStream(values).map(binarySize).anyMatch(BINARY_FOR_SPLIT_THRESHOLD); } /**