This is an automated email from the ASF dual-hosted git repository. daim pushed a commit to branch OAK-11441 in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit 3b3e6b838fbc387aa4448c8a3d5ede6ccfc50d90 Author: Rishabh Kumar <[email protected]> AuthorDate: Thu Jan 30 17:23:37 2025 +0530 OAK-11441 : removed usage of Guava Iterables.addAll --- .../cug/impl/CugAccessControlManager.java | 5 +- .../impl/ReadablePathsAccessControlTest.java | 3 +- .../impl/ReadablePathsPermissionTest.java | 3 +- .../oak/commons/collections/IterableUtils.java | 50 +++++++++++++++ .../oak/commons/collections/IterableUtilsTest.java | 75 ++++++++++++++++++++++ .../index/progress/NodeCounterMBeanEstimator.java | 5 +- .../migration/AbstractDecoratedNodeState.java | 3 +- .../oak/plugins/nodetype/EffectiveType.java | 6 +- .../oak/plugins/nodetype/TypeRegistration.java | 7 +- .../jackrabbit/oak/query/ast/SelectorImpl.java | 3 +- .../permission/PermissionStoreEditor.java | 4 +- .../jackrabbit/oak/jcr/delegate/NodeDelegate.java | 6 +- .../jackrabbit/oak/jcr/binary/BinaryAccessIT.java | 2 +- .../oak/segment/DefaultSegmentWriter.java | 4 +- .../jackrabbit/oak/plugins/document/Commit.java | 3 +- .../oak/plugins/document/DocumentSplitTest.java | 2 +- .../oak/plugins/document/ExternalChangesTest.java | 3 +- .../oak/plugins/document/ManyClusterNodesTest.java | 3 +- .../oak/plugins/memory/PropertyBuilder.java | 3 +- .../oak/upgrade/JackrabbitNodeState.java | 4 +- 20 files changed, 164 insertions(+), 30 deletions(-) diff --git a/oak-authorization-cug/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugAccessControlManager.java b/oak-authorization-cug/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugAccessControlManager.java index 8388e9c019..016f58b451 100644 --- a/oak-authorization-cug/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugAccessControlManager.java +++ b/oak-authorization-cug/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugAccessControlManager.java @@ -26,6 +26,7 @@ import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.IterableUtils; import org.apache.jackrabbit.oak.commons.collections.SetUtils; import org.apache.jackrabbit.oak.namepath.NamePathMapper; import org.apache.jackrabbit.oak.plugins.tree.RootProvider; @@ -367,7 +368,7 @@ class CugAccessControlManager extends AbstractAccessControlManager implements Cu String path = eval.remove(); Tree t = immutableRoot.getTree(path); if (PathUtils.denotesRoot(path)) { - Iterables.addAll(eval, nestedCugPaths(t)); + IterableUtils.addAll(eval, nestedCugPaths(t)); } if (CugUtil.isSupportedPath(path, supportedPaths)) { Tree cug = CugUtil.getCug(t); @@ -376,7 +377,7 @@ class CugAccessControlManager extends AbstractAccessControlManager implements Cu if (!Collections.disjoint(SetUtils.toSet(principalNames), SetUtils.toSet(pNames.getValue(Type.STRINGS)))) { candidates.add(path); } - Iterables.addAll(eval, nestedCugPaths(cug)); + IterableUtils.addAll(eval, nestedCugPaths(cug)); } } } diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/ReadablePathsAccessControlTest.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/ReadablePathsAccessControlTest.java index a610799436..048dfbb8e4 100644 --- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/ReadablePathsAccessControlTest.java +++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/ReadablePathsAccessControlTest.java @@ -21,6 +21,7 @@ import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager; import org.apache.jackrabbit.oak.api.ContentSession; +import org.apache.jackrabbit.oak.commons.collections.IterableUtils; import org.apache.jackrabbit.oak.commons.collections.SetUtils; import org.apache.jackrabbit.oak.commons.jdkcompat.Java23Subject; import org.apache.jackrabbit.oak.commons.PathUtils; @@ -73,7 +74,7 @@ public class ReadablePathsAccessControlTest extends AbstractPrincipalBasedTest { readablePaths = Iterators.cycle(Iterables.transform(paths, f -> getNamePathMapper().getJcrPath(f))); Set<String> childPaths = new HashSet<>(); for (String path : paths) { - Iterables.addAll(childPaths, Iterables.transform(root.getTree(path).getChildren(), tree -> getNamePathMapper().getJcrPath(tree.getPath()))); + IterableUtils.addAll(childPaths, Iterables.transform(root.getTree(path).getChildren(), tree -> getNamePathMapper().getJcrPath(tree.getPath()))); } readableChildPaths = Iterators.cycle(childPaths); } diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/ReadablePathsPermissionTest.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/ReadablePathsPermissionTest.java index 51971480fa..24116e9634 100644 --- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/ReadablePathsPermissionTest.java +++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/ReadablePathsPermissionTest.java @@ -20,6 +20,7 @@ import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.IterableUtils; import org.apache.jackrabbit.oak.plugins.tree.TreeLocation; import org.apache.jackrabbit.oak.spi.namespace.NamespaceConstants; import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters; @@ -64,7 +65,7 @@ public class ReadablePathsPermissionTest extends AbstractPrincipalBasedTest { readablePaths = Iterators.cycle(paths); Set<String> childPaths = new HashSet<>(); for (String path : paths) { - Iterables.addAll(childPaths, Iterables.transform(root.getTree(path).getChildren(), Tree::getPath)); + IterableUtils.addAll(childPaths, Iterables.transform(root.getTree(path).getChildren(), Tree::getPath)); } readableChildPaths = Iterators.cycle(childPaths); diff --git a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/IterableUtils.java b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/IterableUtils.java new file mode 100644 index 0000000000..c849943f86 --- /dev/null +++ b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/IterableUtils.java @@ -0,0 +1,50 @@ +/* + * 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.Collection; +import java.util.Objects; + +/** + * Utility methods for {@link Iterable} conversions and related operations. + */ +public class IterableUtils { + + private IterableUtils() { + // no instances for you + } + + /** + * Adds all elements from the provided iterable to the specified collection. + * + * @param c the collection to which elements are to be added, must not be {@code null} + * @param iterable the iterable whose elements are to be added to the collection, must not be {@code null} + * @param <T> the type of elements in the collection and iterable + * @throws NullPointerException if the collection or iterable is {@code null} + */ + public static <T> void addAll(@NotNull Collection<T> c, @NotNull Iterable<? extends T> iterable) { + Objects.requireNonNull(c); + Objects.requireNonNull(iterable); + + iterable.forEach(c::add); + } + +} diff --git a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/IterableUtilsTest.java b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/IterableUtilsTest.java new file mode 100644 index 0000000000..390d240572 --- /dev/null +++ b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/IterableUtilsTest.java @@ -0,0 +1,75 @@ +/* + * 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.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + + +/** + * Unit tests for the {@link IterableUtils} class. + * <p> + * This class contains test cases to verify the functionality of the methods + * in the {@link IteratorUtils} class. + */ +public class IterableUtilsTest { + + + @Test + public void testAddAllWithNonEmptyIterable() { + List<String> target = new ArrayList<>(); + Iterable<String> source = Arrays.asList("one", "two", "three"); + IterableUtils.addAll(target, source); + Assert.assertEquals(Arrays.asList("one", "two", "three"), target); + } + + @Test + public void testAddAllWithEmptyIterable() { + List<String> target = new ArrayList<>(); + Iterable<String> source = Collections.emptyList(); + IterableUtils.addAll(target, source); + Assert.assertTrue(target.isEmpty()); + } + + @Test + public void testAddAllWithNullCollection() { + Iterable<String> source = Arrays.asList("one", "two", "three"); + Assert.assertThrows(NullPointerException.class, () -> IterableUtils.addAll(null, source)); + } + + @Test + public void testAddAllWithNullIterable() { + List<String> target = new ArrayList<>(); + Assert.assertThrows(NullPointerException.class, () -> IterableUtils.addAll(target, null)); + } + + @Test + public void testAddAllWithCollectionAsIterable() { + List<String> target = new ArrayList<>(List.of("zero")); + List<String> source = Arrays.asList("one", "two", "three"); + IterableUtils.addAll(target, source); + Assert.assertEquals(Arrays.asList("zero", "one", "two", "three"), target); + } + +} \ No newline at end of file diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/progress/NodeCounterMBeanEstimator.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/progress/NodeCounterMBeanEstimator.java index a3d4706117..7c3b03ca27 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/progress/NodeCounterMBeanEstimator.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/progress/NodeCounterMBeanEstimator.java @@ -24,6 +24,7 @@ import java.util.Set; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.IterableUtils; import org.apache.jackrabbit.oak.plugins.index.counter.jmx.NodeCounter; import org.apache.jackrabbit.oak.spi.filter.PathFilter; import org.apache.jackrabbit.oak.spi.state.NodeState; @@ -92,8 +93,8 @@ public class NodeCounterMBeanEstimator implements NodeCountEstimator { return; } - Iterables.addAll(includes, PathFilter.getStrings(idxState.getProperty(PROP_INCLUDED_PATHS), Set.of())); - Iterables.addAll(excludes, PathFilter.getStrings(idxState.getProperty(PROP_EXCLUDED_PATHS), Set.of())); + IterableUtils.addAll(includes, PathFilter.getStrings(idxState.getProperty(PROP_INCLUDED_PATHS), Set.of())); + IterableUtils.addAll(excludes, PathFilter.getStrings(idxState.getProperty(PROP_EXCLUDED_PATHS), Set.of())); } if (includes.isEmpty()) { diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/migration/AbstractDecoratedNodeState.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/migration/AbstractDecoratedNodeState.java index a5a5798261..2177faf5d5 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/migration/AbstractDecoratedNodeState.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/migration/AbstractDecoratedNodeState.java @@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.plugins.migration; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.commons.collections.IterableUtils; import org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState; import org.apache.jackrabbit.oak.plugins.memory.MemoryChildNodeEntry; import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; @@ -96,7 +97,7 @@ public abstract class AbstractDecoratedNodeState extends AbstractNodeState { protected static PropertyState fixChildOrderPropertyState(NodeState nodeState, PropertyState propertyState) { if (propertyState != null && OAK_CHILD_ORDER.equals(propertyState.getName())) { final Collection<String> childNodeNames = new ArrayList<String>(); - Iterables.addAll(childNodeNames, nodeState.getChildNodeNames()); + IterableUtils.addAll(childNodeNames, nodeState.getChildNodeNames()); final Iterable<String> values = Iterables.filter( propertyState.getValue(Type.NAMES), x -> childNodeNames.contains(x)); return PropertyStates.createProperty(OAK_CHILD_ORDER, values, Type.NAMES); diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/EffectiveType.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/EffectiveType.java index f1a6ec07f6..108c754025 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/EffectiveType.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/EffectiveType.java @@ -22,6 +22,7 @@ import java.util.List; import java.util.Set; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.commons.collections.IterableUtils; import org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants; import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry; import org.apache.jackrabbit.oak.spi.state.NodeState; @@ -29,7 +30,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import static java.util.Objects.requireNonNull; -import static org.apache.jackrabbit.guava.common.collect.Iterables.addAll; import static org.apache.jackrabbit.guava.common.collect.Iterables.concat; import static org.apache.jackrabbit.guava.common.collect.Iterables.contains; import static org.apache.jackrabbit.JcrConstants.JCR_DEFAULTPRIMARYTYPE; @@ -262,7 +262,7 @@ class EffectiveType { Set<String> names = new HashSet<>(); for (NodeState type : types) { names.add(type.getName(JCR_NODETYPENAME)); - addAll(names, type.getNames(REP_SUPERTYPES)); + IterableUtils.addAll(names, type.getNames(REP_SUPERTYPES)); } return names; } @@ -308,7 +308,7 @@ class EffectiveType { private Set<String> getNameSet(@NotNull String set) { Set<String> names = new HashSet<>(); for (NodeState type : types) { - addAll(names, type.getNames(set)); + IterableUtils.addAll(names, type.getNames(set)); } return names; } diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeRegistration.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeRegistration.java index 6346e6e6d0..90600e2a96 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeRegistration.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeRegistration.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.plugins.nodetype; -import static org.apache.jackrabbit.guava.common.collect.Iterables.addAll; import static org.apache.jackrabbit.guava.common.collect.Iterables.contains; import static java.util.Collections.emptyList; import static org.apache.jackrabbit.JcrConstants.JCR_CHILDNODEDEFINITION; @@ -127,8 +126,8 @@ class TypeRegistration extends DefaultNodeStateDiff { for (String name : SetUtils.union(changedTypes, removedTypes)) { types.add(name); NodeState type = beforeTypes.getChildNode(name); - addAll(types, type.getNames(REP_PRIMARY_SUBTYPES)); - addAll(types, type.getNames(REP_MIXIN_SUBTYPES)); + org.apache.jackrabbit.oak.commons.collections.IterableUtils.addAll(types, type.getNames(REP_PRIMARY_SUBTYPES)); + org.apache.jackrabbit.oak.commons.collections.IterableUtils.addAll(types, type.getNames(REP_MIXIN_SUBTYPES)); } return types; } @@ -314,7 +313,7 @@ class TypeRegistration extends DefaultNodeStateDiff { private void mergeNameList( NodeBuilder builder, NodeState state, String listName) { Set<String> nameList = SetUtils.toLinkedSet(getNames(builder, listName)); - Iterables.addAll(nameList, state.getProperty(listName).getValue(NAMES)); + org.apache.jackrabbit.oak.commons.collections.IterableUtils.addAll(nameList, state.getProperty(listName).getValue(NAMES)); builder.setProperty(listName, nameList, NAMES); } diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java index f7afa7f689..1527f9fada 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java @@ -34,6 +34,7 @@ import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.LazyValue; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.IterableUtils; import org.apache.jackrabbit.oak.core.ImmutableRoot; import org.apache.jackrabbit.oak.plugins.memory.PropertyBuilder; import org.apache.jackrabbit.oak.plugins.metric.util.StatsProviderUtil; @@ -739,7 +740,7 @@ public class SelectorImpl extends SourceImpl { if (type == Type.STRING) { ArrayList<String> strings = new ArrayList<String>(); for (PropertyValue p : list) { - Iterables.addAll(strings, p.getValue(Type.STRINGS)); + IterableUtils.addAll(strings, p.getValue(Type.STRINGS)); } return PropertyValues.newString(strings); } diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionStoreEditor.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionStoreEditor.java index c7ce5a2c46..5337581bb7 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionStoreEditor.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionStoreEditor.java @@ -24,6 +24,7 @@ import java.util.Set; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.StringUtils; +import org.apache.jackrabbit.oak.commons.collections.IterableUtils; import org.apache.jackrabbit.oak.commons.collections.SetUtils; import org.apache.jackrabbit.oak.plugins.nodetype.TypePredicate; import org.apache.jackrabbit.oak.security.authorization.ProviderCtx; @@ -43,7 +44,6 @@ import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.apache.jackrabbit.guava.common.collect.Iterables.addAll; import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.oak.plugins.tree.TreeConstants.OAK_CHILD_ORDER; @@ -77,7 +77,7 @@ final class PermissionStoreEditor implements AccessControlConstants, PermissionC Set<String> orderedChildNames = SetUtils.toLinkedSet(node.getNames(OAK_CHILD_ORDER)); long n = orderedChildNames.size(); if (node.getChildNodeCount(n + 1) > n) { - addAll(orderedChildNames, node.getChildNodeNames()); + IterableUtils.addAll(orderedChildNames, node.getChildNodeNames()); } int index = 0; diff --git a/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/NodeDelegate.java b/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/NodeDelegate.java index 22709a42b7..8d0aa1ac9f 100644 --- a/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/NodeDelegate.java +++ b/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/NodeDelegate.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.jcr.delegate; -import static org.apache.jackrabbit.guava.common.collect.Iterables.addAll; import static org.apache.jackrabbit.guava.common.collect.Iterables.contains; import static org.apache.jackrabbit.guava.common.collect.Iterators.filter; import static org.apache.jackrabbit.guava.common.collect.Iterators.transform; @@ -79,6 +78,7 @@ import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Tree.Status; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.IterableUtils; import org.apache.jackrabbit.oak.commons.collections.SetUtils; import org.apache.jackrabbit.oak.jcr.lock.LockDeprecation; import org.apache.jackrabbit.oak.plugins.identifier.IdentifierManager; @@ -172,7 +172,7 @@ public class NodeDelegate extends ItemDelegate { Set<String> typeNames = new HashSet<>(); for (Tree type : TreeUtil.getEffectiveType(tree, typeRoot)) { typeNames.add(TreeUtil.getName(type, JCR_NODETYPENAME)); - addAll(typeNames, TreeUtil.getNames(type, REP_SUPERTYPES)); + IterableUtils.addAll(typeNames, TreeUtil.getNames(type, REP_SUPERTYPES)); } for (Tree type : types) { @@ -450,7 +450,7 @@ public class NodeDelegate extends ItemDelegate { Set<String> typeNames = new LinkedHashSet<>(); for (Tree type : getNodeTypes(child, typeRoot)) { typeNames.add(TreeUtil.getName(type, JCR_NODETYPENAME)); - addAll(typeNames, getNames(type, REP_SUPERTYPES)); + IterableUtils.addAll(typeNames, getNames(type, REP_SUPERTYPES)); } Tree oldDefinition = findMatchingChildNodeDefinition(removed, name, typeNames); diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/binary/BinaryAccessIT.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/binary/BinaryAccessIT.java index 22c5e6098f..ca15e92b2f 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/binary/BinaryAccessIT.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/binary/BinaryAccessIT.java @@ -156,7 +156,7 @@ public class BinaryAccessIT extends AbstractBinaryAccessIT { assertNotNull(upload); List<URI> uris = new ArrayList<>(); - Iterables.addAll(uris, upload.getUploadURIs()); + org.apache.jackrabbit.oak.commons.collections.IterableUtils.addAll(uris, upload.getUploadURIs()); // this follows the upload algorithm from BinaryUpload if (content.size() / upload.getMaxPartSize() > uris.size()) { diff --git a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/DefaultSegmentWriter.java b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/DefaultSegmentWriter.java index ca0d22b140..e8c5f0e7ca 100644 --- a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/DefaultSegmentWriter.java +++ b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/DefaultSegmentWriter.java @@ -29,7 +29,6 @@ import static java.util.Objects.requireNonNull; import static org.apache.jackrabbit.oak.commons.conditions.Validate.checkArgument; import static org.apache.jackrabbit.guava.common.base.Preconditions.checkPositionIndex; -import static org.apache.jackrabbit.guava.common.collect.Iterables.addAll; import static org.apache.jackrabbit.oak.api.Type.BINARIES; import static org.apache.jackrabbit.oak.api.Type.BINARY; import static org.apache.jackrabbit.oak.api.Type.NAME; @@ -61,6 +60,7 @@ import org.apache.jackrabbit.oak.api.Blob; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.Buffer; +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.blob.BlobStoreBlob; @@ -433,7 +433,7 @@ public class DefaultSegmentWriter implements SegmentWriter { List<MapEntry> list = new ArrayList<>(); for (MapRecord bucket : buckets) { if (bucket != null) { - addAll(list, bucket.getEntries()); + IterableUtils.addAll(list, bucket.getEntries()); } } return writeMapLeaf(level, list); diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java index b57af7fee4..6c1ec0b437 100644 --- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java +++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java @@ -31,6 +31,7 @@ import java.util.TreeSet; import java.util.concurrent.TimeUnit; import org.apache.jackrabbit.guava.common.collect.Iterables; +import org.apache.jackrabbit.oak.commons.collections.IterableUtils; import org.apache.jackrabbit.oak.commons.collections.ListUtils; import org.apache.jackrabbit.oak.commons.json.JsopStream; import org.apache.jackrabbit.oak.commons.json.JsopWriter; @@ -683,7 +684,7 @@ public class Commit { checkConflicts(op, doc); } catch (ConflictException e) { exceptions.add(e); - Iterables.addAll(revisions, e.getConflictRevisions()); + IterableUtils.addAll(revisions, e.getConflictRevisions()); } } if (!exceptions.isEmpty()) { diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java index 1b254f9174..3298f195a9 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java @@ -888,7 +888,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest { } Set<Revision> revs = new HashSet<>(); for (RevisionVector rv : revisions) { - Iterables.addAll(revs, rv); + org.apache.jackrabbit.oak.commons.collections.IterableUtils.addAll(revs, rv); } revs.removeAll(doc.getValueMap("_deleted").keySet()); assertTrue("Missing _deleted entries on " + doc.getId() + ": " + revs, revs.isEmpty()); diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ExternalChangesTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ExternalChangesTest.java index d78262daf4..75fec7348f 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ExternalChangesTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ExternalChangesTest.java @@ -27,6 +27,7 @@ import java.util.Set; import org.apache.jackrabbit.guava.common.base.Splitter; import org.apache.jackrabbit.guava.common.collect.Iterables; +import org.apache.jackrabbit.oak.commons.collections.IterableUtils; import org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore; import org.apache.jackrabbit.oak.plugins.document.spi.JournalProperty; import org.apache.jackrabbit.oak.plugins.document.spi.JournalPropertyBuilder; @@ -306,7 +307,7 @@ public class ExternalChangesTest { @Override public void addSerializedProperty(@Nullable String s) { if (s != null){ - Iterables.addAll(allProps.values, Splitter.on(',').split(s)); + IterableUtils.addAll(allProps.values, Splitter.on(',').split(s)); } } diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ManyClusterNodesTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ManyClusterNodesTest.java index 91cf923a4e..b7895b1b5f 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ManyClusterNodesTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ManyClusterNodesTest.java @@ -23,6 +23,7 @@ import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.commons.collections.IterableUtils; import org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore; import org.apache.jackrabbit.oak.plugins.document.util.Utils; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; @@ -72,7 +73,7 @@ public class ManyClusterNodesTest { PropertyState p = test.getProperty("p"); List<String> values = new ArrayList<>(); if (p != null) { - Iterables.addAll(values, p.getValue(Type.STRINGS)); + IterableUtils.addAll(values, p.getValue(Type.STRINGS)); } values.add(value); test.setProperty("p", values, Type.STRINGS); diff --git a/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/plugins/memory/PropertyBuilder.java b/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/plugins/memory/PropertyBuilder.java index 938e17d95f..87f807a1b0 100644 --- a/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/plugins/memory/PropertyBuilder.java +++ b/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/plugins/memory/PropertyBuilder.java @@ -28,6 +28,7 @@ import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.api.Blob; import org.apache.jackrabbit.oak.api.PropertyState; 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.commons.conditions.Validate; import org.jetbrains.annotations.NotNull; @@ -251,7 +252,7 @@ public class PropertyBuilder<T> { @NotNull public PropertyBuilder<T> addValues(Iterable<T> values) { - Iterables.addAll(this.values, values); + IterableUtils.addAll(this.values, values); return this; } diff --git a/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/JackrabbitNodeState.java b/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/JackrabbitNodeState.java index db5bf90ebf..32a5741073 100644 --- a/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/JackrabbitNodeState.java +++ b/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/JackrabbitNodeState.java @@ -18,7 +18,6 @@ package org.apache.jackrabbit.oak.upgrade; import static org.apache.jackrabbit.oak.commons.conditions.Validate.checkArgument; import static java.util.Objects.requireNonNull; -import static org.apache.jackrabbit.guava.common.collect.Iterables.addAll; import static org.apache.jackrabbit.JcrConstants.JCR_FROZENMIXINTYPES; import static org.apache.jackrabbit.JcrConstants.JCR_FROZENPRIMARYTYPE; @@ -70,6 +69,7 @@ import org.apache.jackrabbit.oak.api.Blob; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.IterableUtils; import org.apache.jackrabbit.oak.commons.conditions.Validate; import org.apache.jackrabbit.oak.plugins.memory.AbstractBlob; import org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState; @@ -447,7 +447,7 @@ class JackrabbitNodeState extends AbstractNodeState { } property = properties.get(JCR_FROZENMIXINTYPES); if (property != null && property.getType() == NAMES) { - addAll(frozenMixins, property.getValue(NAMES)); + IterableUtils.addAll(frozenMixins, property.getValue(NAMES)); } if (!isReferenceable.test(frozenPrimary, frozenMixins)) {
