You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by da...@apache.org on 2024/12/17 08:23:47 UTC
(jackrabbit-oak) branch OAK-11190 created (now 1ccddd8146)
This is an automated email from the ASF dual-hosted git repository.
daim pushed a change to branch OAK-11190
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
at 1ccddd8146 OAK-11190 : removed usage of guava immutablelist.copyOf
This branch includes the following new commits:
new 1ccddd8146 OAK-11190 : removed usage of guava immutablelist.copyOf
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(jackrabbit-oak) 01/01: OAK-11190 : removed usage of guava immutablelist.copyOf
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
daim pushed a commit to branch OAK-11190
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit 1ccddd81467b34cc76ce36218df7694d96616682
Author: Rishabh Kumar <di...@adobe.com>
AuthorDate: Tue Dec 17 13:53:33 2024 +0530
OAK-11190 : removed usage of guava immutablelist.copyOf
---
.../external/impl/AbstractDynamicTest.java | 6 ++--
.../external/impl/DynamicGroupsTest.java | 6 ++--
.../external/impl/DynamicSyncContextTest.java | 2 +-
.../ExternalGroupPrincipalProviderTest.java | 4 +--
.../impl/principal/ExternalGroupPrincipalTest.java | 3 +-
.../principalbased/impl/MockUtility.java | 4 +--
.../PrincipalBasedAccessControlManagerTest.java | 7 ++--
.../impl/PrincipalPolicyImplTest.java | 4 +--
.../impl/PrincipalPolicyImporterTest.java | 3 +-
.../GetPrivilegeCollectionIncludeNamesTest.java | 2 +-
.../principalbased/PermissionEvaluationTest.java | 4 +--
.../principalbased/PrinicipalBasedReadTest.java | 5 ++-
.../oak/commons/collections/CollectionUtils.java | 36 ++++++++++++++++++++
.../oak/commons/collections/package-info.java | 2 +-
.../commons/FileLineDifferenceIteratorTest.java | 8 ++---
.../commons/collections/CollectionUtilsTest.java | 38 ++++++++++++++++++++++
.../oak/commons/sort/StringSortTest.java | 3 +-
.../oak/spi/whiteboard/WhiteboardUtils.java | 3 +-
.../index/CompositeIndexEditorProvider.java | 5 ++-
.../jackrabbit/oak/plugins/index/IndexUtils.java | 3 +-
.../oak/plugins/index/inventory/IndexPrinter.java | 4 +--
.../plugins/version/ReadWriteVersionManager.java | 2 +-
.../index/importer/IndexDefinitionUpdaterTest.java | 4 +--
.../strategy/ContentMirrorStoreStrategyTest.java | 10 +++---
.../oak/query/TraversalAvoidanceTest.java | 3 +-
.../accesscontrol/AccessControlValidatorTest.java | 3 +-
.../CompositeAccessControlManagerTest.java | 2 +-
.../composite/CompositeProviderFullScopeTest.java | 4 +--
.../CompositeProviderGetTreePermissionTest.java | 4 +--
.../composite/CompositeProviderSupportedTest.java | 4 +--
.../permission/ChildOrderDiffTest.java | 4 +--
.../user/AddMembersByIdBestEffortTest.java | 4 +--
.../oak/security/user/PasswordHistoryTest.java | 5 ++-
.../user/UserImporterMembershipIgnoreTest.java | 9 ++---
.../security/user/query/UserQueryManagerTest.java | 5 +--
.../index/lucene/IndexAugmentorFactory.java | 4 +--
.../oak/plugins/index/lucene/hybrid/NRTIndex.java | 4 +--
.../oak/plugins/index/lucene/LuceneIndexTest.java | 4 +--
.../index/lucene/property/BucketSwitcherTest.java | 24 +++++++-------
.../property/HybridPropertyIndexLookupTest.java | 10 +++---
.../property/HybridPropertyIndexStorageTest.java | 4 +--
.../lucene/property/PropertyIndexCleanerTest.java | 4 +--
.../lucene/property/UniqueIndexCleanerTest.java | 6 ++--
.../oak/spi/query/CompositeQueryIndexProvider.java | 3 +-
.../document/flatfile/SimpleFlatFileUtil.java | 4 +--
.../document/flatfile/SimpleNodeStateHolder.java | 4 +--
.../document/flatfile/StateInBytesHolder.java | 4 +--
.../flatfile/ChildNodeStateProviderTest.java | 22 ++++++-------
.../flatfile/NodeStateEntryWriterTest.java | 14 ++++----
.../index/indexer/document/flatfile/TestUtils.java | 4 +--
.../oak/plugins/index/search/Aggregate.java | 4 +--
.../plugins/index/search/PropertyDefinition.java | 6 ++--
.../oak/spi/security/CompositeConfiguration.java | 10 +++---
.../token/CompositeTokenProvider.java | 5 ++-
.../authorization/accesscontrol/ImmutableACL.java | 4 +--
.../apache/jackrabbit/oak/spi/xml/PropInfo.java | 3 +-
.../authorization/accesscontrol/ACETest.java | 3 +-
.../oak/plugins/document/NodeDocument.java | 3 +-
.../oak/plugins/document/bundlor/BundlorUtils.java | 4 +--
.../plugins/document/bundlor/DocumentBundlor.java | 3 +-
.../oak/plugins/document/bundlor/Include.java | 4 +--
.../document/secondary/SecondaryStoreBuilder.java | 4 +--
.../document/BlobReferenceIteratorTest.java | 4 +--
.../oak/plugins/document/DocumentSplitTest.java | 15 ++++-----
.../document/VersionGarbageCollectorIT.java | 16 ++++-----
.../document/bundlor/DocumentBundlingTest.java | 4 +--
.../apache/jackrabbit/oak/json/JsonSerializer.java | 4 +--
.../jackrabbit/oak/upgrade/RepositoryUpgrade.java | 4 +--
.../oak/upgrade/PrivilegeUpgradeTest.java | 4 +--
69 files changed, 256 insertions(+), 178 deletions(-)
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 4190916655..b839bd8568 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
@@ -16,12 +16,12 @@
*/
package org.apache.jackrabbit.oak.spi.security.authentication.external.impl;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.guava.common.collect.Iterators;
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.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 @@ public abstract class AbstractDynamicTest extends AbstractExternalAuthTest {
@NotNull
static List<String> getIds(@NotNull Iterator<? extends Authorizable> authorizables) {
- return ImmutableList.copyOf(Iterators.transform(authorizables, authorizable -> {
+ return CollectionUtils.toImmutableList(Iterators.transform(authorizables, authorizable -> {
try {
return authorizable.getID();
} catch (RepositoryException repositoryException) {
@@ -127,6 +127,6 @@ public abstract class AbstractDynamicTest extends AbstractExternalAuthTest {
@NotNull
static List<String> getPrincipalNames(@NotNull Iterator<Principal> groupPrincipals) {
- return ImmutableList.copyOf(Iterators.transform(groupPrincipals, Principal::getName));
+ return CollectionUtils.toImmutableList(Iterators.transform(groupPrincipals, Principal::getName));
}
}
\ No newline at end of file
diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicGroupsTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicGroupsTest.java
index a398d75482..5cb5d3137c 100644
--- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicGroupsTest.java
+++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicGroupsTest.java
@@ -16,9 +16,6 @@
*/
package org.apache.jackrabbit.oak.spi.security.authentication.external.impl;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
-import org.apache.jackrabbit.guava.common.collect.Iterators;
-import org.apache.jackrabbit.guava.common.collect.Lists;
import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal;
import org.apache.jackrabbit.api.security.principal.PrincipalManager;
import org.apache.jackrabbit.api.security.user.Authorizable;
@@ -26,6 +23,7 @@ import org.apache.jackrabbit.api.security.user.Group;
import org.apache.jackrabbit.api.security.user.User;
import org.apache.jackrabbit.api.security.user.UserManager;
import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup;
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity;
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityProvider;
@@ -294,7 +292,7 @@ public class DynamicGroupsTest extends DynamicSyncContextTest {
UserManager um = getUserManager(r);
PrincipalManager pm = getPrincipalManager(r);
- List<ExternalIdentityRef> declaredGroupRefs = ImmutableList.copyOf(previouslySyncedUser.getDeclaredGroups());
+ List<ExternalIdentityRef> declaredGroupRefs = CollectionUtils.toImmutableList(previouslySyncedUser.getDeclaredGroups());
assertTrue(declaredGroupRefs.size() > 1);
String groupId = declaredGroupRefs.get(0).getId();
diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicSyncContextTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicSyncContextTest.java
index 40106a4399..7f2cd7d07d 100644
--- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicSyncContextTest.java
+++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicSyncContextTest.java
@@ -119,7 +119,7 @@ public class DynamicSyncContextTest extends AbstractDynamicTest {
private void assertDynamicMembership(@NotNull Authorizable a, @NotNull ExternalIdentity externalIdentity, long depth) throws Exception {
Value[] vs = a.getProperty(REP_EXTERNAL_PRINCIPAL_NAMES);
- Set<String> pNames = ImmutableList.copyOf(vs).stream().map(value -> {
+ Set<String> pNames = CollectionUtils.toImmutableList(vs).stream().map(value -> {
try {
return value.getString();
} catch (RepositoryException e) {
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 3fa32144a9..169c8a9b7e 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
@@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.ImmutableSet;
import org.apache.jackrabbit.api.security.principal.GroupPrincipal;
import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal;
@@ -29,6 +28,7 @@ import org.apache.jackrabbit.oak.api.QueryEngine;
import org.apache.jackrabbit.oak.api.Root;
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.namepath.NamePathMapper;
import org.apache.jackrabbit.oak.plugins.tree.TreeAware;
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup;
@@ -593,7 +593,7 @@ public class ExternalGroupPrincipalProviderTest extends AbstractPrincipalTest {
return in.iterator();
}
};
- List<Principal> out = ImmutableList.copyOf(p.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_ALL, 0, -1));
+ List<Principal> out = CollectionUtils.toImmutableList(p.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_ALL, 0, -1));
Collections.sort(in, Comparator.comparing(Principal::getName));
assertEquals(in, out);
}
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 78e5bb6ac6..c99c1b6a6b 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
@@ -26,6 +26,7 @@ import org.apache.jackrabbit.api.security.user.UserManager;
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.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;
@@ -80,7 +81,7 @@ public class ExternalGroupPrincipalTest extends AbstractPrincipalTest {
public void testIsMemberExternalGroup() throws Exception {
GroupPrincipal principal = getGroupPrincipal();
- Iterable<String> exGroupPrincNames = Iterables.transform(ImmutableList.copyOf(idp.listGroups()), ExternalIdentity::getPrincipalName);
+ Iterable<String> exGroupPrincNames = Iterables.transform(CollectionUtils.toImmutableList(idp.listGroups()), ExternalIdentity::getPrincipalName);
for (String principalName : exGroupPrincNames) {
assertFalse(principal.isMember(new PrincipalImpl(principalName)));
}
diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/MockUtility.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/MockUtility.java
index 6d87333b09..ef8407cbc9 100644
--- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/MockUtility.java
+++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/MockUtility.java
@@ -16,13 +16,13 @@
*/
package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.oak.api.PropertyState;
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.CollectionUtils;
import org.apache.jackrabbit.oak.namepath.NamePathMapper;
import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
import org.apache.jackrabbit.oak.plugins.tree.ReadOnly;
@@ -98,7 +98,7 @@ final class MockUtility {
}
static PropertyState createMixinTypesProperty(@NotNull String... mixinTypes) {
- return PropertyStates.createProperty(JcrConstants.JCR_MIXINTYPES, ImmutableList.copyOf(mixinTypes), Type.NAMES);
+ return PropertyStates.createProperty(JcrConstants.JCR_MIXINTYPES, CollectionUtils.toImmutableList(mixinTypes), Type.NAMES);
}
static FilterProvider mockFilterProvider(boolean canHandle) {
diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalBasedAccessControlManagerTest.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalBasedAccessControlManagerTest.java
index f00ce03e00..2f2af8b59e 100644
--- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalBasedAccessControlManagerTest.java
+++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalBasedAccessControlManagerTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.ImmutableSet;
import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.api.security.JackrabbitAccessControlPolicy;
@@ -25,6 +24,7 @@ import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal;
import org.apache.jackrabbit.oak.api.Root;
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.plugins.tree.TreeUtil;
import org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants;
import org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration;
@@ -49,7 +49,6 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import java.util.stream.Collectors;
import static org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl.Constants.MIX_REP_PRINCIPAL_BASED_MIXIN;
import static org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl.Constants.REP_PRINCIPAL_POLICY;
@@ -556,7 +555,7 @@ public class PrincipalBasedAccessControlManagerTest extends AbstractPrincipalBas
Iterator<AccessControlPolicy> effective = acMgr.getEffectivePolicies(principals, new String[0]);
AccessControlPolicy[] expected = acMgr.getEffectivePolicies(principals);
- assertArrayEquals(expected, ImmutableList.copyOf(effective).toArray(new AccessControlPolicy[0]));
+ assertArrayEquals(expected, CollectionUtils.toImmutableList(effective).toArray(new AccessControlPolicy[0]));
}
@Test
@@ -569,7 +568,7 @@ public class PrincipalBasedAccessControlManagerTest extends AbstractPrincipalBas
String[] paths = readablePaths.stream().map(oakPath -> namePathMapper.getJcrPath(oakPath)).distinct().toArray(String[]::new);
assertEquals(3, paths.length);
- List<AccessControlPolicy> effective = ImmutableList.copyOf(acMgr.getEffectivePolicies(Collections.singleton(validPrincipal), paths));
+ List<AccessControlPolicy> effective = CollectionUtils.toImmutableList(acMgr.getEffectivePolicies(Collections.singleton(validPrincipal), paths));
assertEquals(1, effective.size());
assertEquals(ReadPolicy.INSTANCE, effective.get(0));
diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImplTest.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImplTest.java
index f27ed5f556..80b3105a17 100644
--- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImplTest.java
+++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImplTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.api.security.authorization.PrincipalAccessControlList;
import org.apache.jackrabbit.api.security.authorization.PrivilegeCollection;
@@ -25,6 +24,7 @@ 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.PathUtils;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
import org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants;
import org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AccessControlConstants;
@@ -140,7 +140,7 @@ public class PrincipalPolicyImplTest extends AbstractPrincipalBasedTest {
Tree t = mock(Tree.class);
PropertyState path = PropertyStates.createProperty(REP_EFFECTIVE_PATH, oakPath);
when(t.getProperty(REP_EFFECTIVE_PATH)).thenReturn(path);
- PropertyState privs = PropertyStates.createProperty(REP_PRIVILEGES, ImmutableList.copyOf(privilegeNames), Type.NAMES);
+ PropertyState privs = PropertyStates.createProperty(REP_PRIVILEGES, CollectionUtils.toImmutableList(privilegeNames), Type.NAMES);
when(t.getProperty(REP_PRIVILEGES)).thenReturn(privs);
Tree rTree = when(mock(Tree.class).getProperties()).thenReturn(Collections.emptySet()).getMock();
when(t.getChild(REP_RESTRICTIONS)).thenReturn(rTree);
diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImporterTest.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImporterTest.java
index b969900f80..1236f047d1 100644
--- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImporterTest.java
+++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImporterTest.java
@@ -22,6 +22,7 @@ import org.apache.jackrabbit.guava.common.collect.Maps;
import org.apache.jackrabbit.api.security.user.User;
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.plugins.tree.TreeUtil;
import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
import org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration;
@@ -151,7 +152,7 @@ public class PrincipalPolicyImporterTest extends AbstractPrincipalBasedTest {
List<PropInfo> propInfos = new ArrayList();
for (Map.Entry<String,Value[]> r : restrictions.entrySet()) {
String jcrName = r.getKey();
- List<Value> vs = ImmutableList.copyOf(r.getValue());
+ List<Value> vs = CollectionUtils.toImmutableList(r.getValue());
PropInfo propInfo = mockPropInfo(jcrName);
if (!vs.isEmpty()) {
TextValue first = when(mock(TextValue.class).getString()).thenReturn(vs.get(0).getString()).getMock();
diff --git a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/GetPrivilegeCollectionIncludeNamesTest.java b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/GetPrivilegeCollectionIncludeNamesTest.java
index 3e9a471898..9264bc3be6 100644
--- a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/GetPrivilegeCollectionIncludeNamesTest.java
+++ b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/GetPrivilegeCollectionIncludeNamesTest.java
@@ -44,7 +44,7 @@ public class GetPrivilegeCollectionIncludeNamesTest extends AbstractHasItemGetIt
ACCESSCONTORL_MANAGER_HAS_PRIVILEGES
}
- private static final List<String> ALL_PRIVILEGE_NAMES = ImmutableList.copyOf(PrivilegeBits.BUILT_IN.keySet());
+ private static final List<String> ALL_PRIVILEGE_NAMES = CollectionUtils.toImmutableList(PrivilegeBits.BUILT_IN.keySet());
private final EvaluationType evalType;
diff --git a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/principalbased/PermissionEvaluationTest.java b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/principalbased/PermissionEvaluationTest.java
index f9b41678e3..158e5087a9 100644
--- a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/principalbased/PermissionEvaluationTest.java
+++ b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/principalbased/PermissionEvaluationTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.jackrabbit.oak.benchmark.authorization.principalbased;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.spi.security.authorization.permission.Permissions;
import org.jetbrains.annotations.NotNull;
@@ -38,7 +38,7 @@ public class PermissionEvaluationTest extends PrinicipalBasedReadTest {
logout = true;
}
try {
- List<String> permissionNames = ImmutableList.copyOf(Permissions.PERMISSION_NAMES.values());
+ List<String> permissionNames = CollectionUtils.toImmutableList(Permissions.PERMISSION_NAMES.values());
int access = 0;
int noAccess = 0;
long start = System.currentTimeMillis();
diff --git a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/principalbased/PrinicipalBasedReadTest.java b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/principalbased/PrinicipalBasedReadTest.java
index 4fa7ed3703..7a0a2843d6 100644
--- a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/principalbased/PrinicipalBasedReadTest.java
+++ b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/principalbased/PrinicipalBasedReadTest.java
@@ -16,8 +16,6 @@
*/
package org.apache.jackrabbit.oak.benchmark.authorization.principalbased;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
-
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.guava.common.collect.Iterators;
import org.apache.jackrabbit.api.JackrabbitSession;
@@ -31,6 +29,7 @@ import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils
import org.apache.jackrabbit.oak.benchmark.ReadDeepTreeTest;
import org.apache.jackrabbit.oak.benchmark.authorization.Utils;
import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.composite.MountInfoProviderService;
import org.apache.jackrabbit.oak.fixture.OakRepositoryFixture;
import org.apache.jackrabbit.oak.fixture.RepositoryFixture;
@@ -161,7 +160,7 @@ public class PrinicipalBasedReadTest extends ReadDeepTreeTest {
}
added = acl.addAccessControlEntry(principal, privileges);
} else {
- for (JackrabbitAccessControlPolicy policy : Iterables.concat(ImmutableList.copyOf(acMgr.getApplicablePolicies(principal)), ImmutableList.copyOf(acMgr.getPolicies(principal)))) {
+ for (JackrabbitAccessControlPolicy policy : Iterables.concat(CollectionUtils.toImmutableList(acMgr.getApplicablePolicies(principal)), CollectionUtils.toImmutableList(acMgr.getPolicies(principal)))) {
if (policy instanceof PrincipalAccessControlList) {
acl = (PrincipalAccessControlList) policy;
break;
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 d888c5a7ba..37267283f3 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
@@ -67,6 +67,42 @@ public class CollectionUtils {
return result;
}
+ /**
+ * Convert an iterable to an immutable list. The returning list is immutable and neither support any modification and nor null values.
+ * @param iterable the iterable to convert
+ * @return the list
+ * @param <T> the type of the elements
+ */
+ @NotNull
+ public static <T> List<T> toImmutableList(@NotNull final Iterable<? extends T> iterable) {
+ Objects.requireNonNull(iterable);
+ return toStream(iterable).filter(Objects::nonNull).collect(Collectors.toUnmodifiableList());
+ }
+
+ /**
+ * Convert an iterator to an immutable list. The returning list is immutable and neither support any modification and nor null values.
+ * @param iterator the iterable to convert
+ * @return the list
+ * @param <T> the type of the elements
+ */
+ @NotNull
+ public static <T> List<T> toImmutableList(@NotNull final Iterator<? extends T> iterator) {
+ Objects.requireNonNull(iterator);
+ return toStream(iterator).filter(Objects::nonNull).collect(Collectors.toUnmodifiableList());
+ }
+
+ /**
+ * Convert an vararg list of items to an immutable list. The returning list is immutable and neither support any modification and nor null values.
+ * @param elements the iterable to convert
+ * @return the list
+ * @param <T> the type of the elements
+ */
+ @NotNull
+ public static <T> List<T> toImmutableList(@NotNull final T... elements) {
+ Objects.requireNonNull(elements);
+ return Stream.of(elements).filter(Objects::nonNull).collect(Collectors.toUnmodifiableList());
+ }
+
/**
* Convert an iterable to a {@link java.util.LinkedList}. The returning LinkedList is mutable and supports all optional operations.
* @param iterable the iterator to convert
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 11a3fa317b..df06d85d18 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("1.3.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/FileLineDifferenceIteratorTest.java b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/FileLineDifferenceIteratorTest.java
index 8011eb15b6..57eb2b3987 100644
--- a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/FileLineDifferenceIteratorTest.java
+++ b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/FileLineDifferenceIteratorTest.java
@@ -37,7 +37,7 @@ import java.util.function.Function;
import org.apache.commons.io.LineIterator;
import org.apache.jackrabbit.guava.common.base.Splitter;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.commons.io.FileLineDifferenceIterator;
import org.jetbrains.annotations.Nullable;
import org.junit.Test;
@@ -159,12 +159,12 @@ public class FileLineDifferenceIteratorTest {
private static void assertReverseDiff(String marked, String all, List<String> diff) throws IOException {
Iterator<String> itr = createItr(all, marked);
- assertThat("marked: " + marked + " all: " + all, ImmutableList.copyOf(itr), is(diff));
+ assertThat("marked: " + marked + " all: " + all, CollectionUtils.toImmutableList(itr), is(diff));
}
private static void assertDiff(String marked, String all, List<String> diff) throws IOException {
Iterator<String> itr = createItr(marked, all);
- assertThat("marked: " + marked + " all: " + all, ImmutableList.copyOf(itr), is(diff));
+ assertThat("marked: " + marked + " all: " + all, CollectionUtils.toImmutableList(itr), is(diff));
}
private static Iterator<String> createItr(String marked, String all) throws IOException {
@@ -189,6 +189,6 @@ public class FileLineDifferenceIteratorTest {
}
});
- assertThat("marked: " + marked + " all: " + all, ImmutableList.copyOf(itr), is(diff));
+ assertThat("marked: " + marked + " all: " + all, CollectionUtils.toImmutableList(itr), is(diff));
}
}
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 018a3fcc43..1dd6b7a382 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
@@ -49,6 +49,44 @@ public class CollectionUtilsTest {
}
+ @Test(expected = UnsupportedOperationException.class)
+ public void iterableToImmutableList() {
+ // create a set of non-null values
+ final List<String> s = data.stream().filter(Objects::nonNull).collect(Collectors.toList());
+ final Iterable<String> iterable = new SimpleIterable<>(s);
+
+ final List<String> immutableList = CollectionUtils.toImmutableList(iterable);
+ Assert.assertEquals(s, immutableList);
+ // should throw exception
+ immutableList.add("four");
+ fail("Shouldn't reach here");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void iteratorToImmutableList() {
+ // create a set of non-null values
+ final List<String> s = data.stream().filter(Objects::nonNull).collect(Collectors.toList());
+ final Iterable<String> iterable = new SimpleIterable<>(s);
+
+ final List<String> immutableList = CollectionUtils.toImmutableList(iterable.iterator());
+ Assert.assertEquals(s, immutableList);
+ // should throw exception
+ immutableList.add("four");
+ fail("Shouldn't reach here");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void varargsToImmutableList() {
+ // create a set of non-null values
+ final List<String> s = data.stream().filter(Objects::nonNull).collect(Collectors.toList());
+
+ final List<String> immutableList = CollectionUtils.toImmutableList("one", "two", null, "three");
+ Assert.assertEquals(s, immutableList);
+ // should throw exception
+ immutableList.add("four");
+ fail("Shouldn't reach here");
+ }
+
@Test
public void iterableToLinkedList() {
// create an iterable
diff --git a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/sort/StringSortTest.java b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/sort/StringSortTest.java
index cf8423038a..4abb117bf8 100644
--- a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/sort/StringSortTest.java
+++ b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/sort/StringSortTest.java
@@ -29,7 +29,6 @@ import java.util.List;
import java.util.Set;
import org.apache.commons.collections4.CollectionUtils;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@@ -106,7 +105,7 @@ public class StringSortTest {
Collections.sort(paths, comparator);
collector.sort();
- List<String> sortedPaths = ImmutableList.copyOf(collector.getIds());
+ List<String> sortedPaths = org.apache.jackrabbit.oak.commons.collections.CollectionUtils.toImmutableList(collector.getIds());
assertEquals(paths.size(), sortedPaths.size());
assertEquals(paths, sortedPaths);
}
diff --git a/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/whiteboard/WhiteboardUtils.java b/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/whiteboard/WhiteboardUtils.java
index 3b6eda2011..5cdae83740 100644
--- a/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/whiteboard/WhiteboardUtils.java
+++ b/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/whiteboard/WhiteboardUtils.java
@@ -26,6 +26,7 @@ import java.util.function.Predicate;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.commons.jmx.JmxUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -165,7 +166,7 @@ public class WhiteboardUtils {
if (predicate == null) {
return tracker.getServices();
} else {
- return ImmutableList.copyOf(Iterables.filter(tracker.getServices(), (input) -> predicate.test(input)));
+ return CollectionUtils.toImmutableList(Iterables.filter(tracker.getServices(), (input) -> predicate.test(input)));
}
} finally {
tracker.stop();
diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/CompositeIndexEditorProvider.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/CompositeIndexEditorProvider.java
index aa2f2b4c50..adfbb381eb 100644
--- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/CompositeIndexEditorProvider.java
+++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/CompositeIndexEditorProvider.java
@@ -22,14 +22,13 @@ import java.util.Collection;
import java.util.List;
import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.spi.commit.CompositeEditor;
import org.apache.jackrabbit.oak.spi.commit.Editor;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
import org.apache.jackrabbit.oak.spi.state.NodeState;
import org.jetbrains.annotations.NotNull;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
-
/**
* Aggregation of a list of editor providers into a single provider.
*/
@@ -50,7 +49,7 @@ public class CompositeIndexEditorProvider implements IndexEditorProvider {
return providers.iterator().next();
} else {
return new CompositeIndexEditorProvider(
- ImmutableList.copyOf(providers));
+ CollectionUtils.toImmutableList(providers));
}
}
diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java
index a35ee9fe42..db28d3ffe5 100644
--- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java
+++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java
@@ -42,7 +42,6 @@ import java.util.stream.StreamSupport;
import javax.jcr.RepositoryException;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.Tree;
@@ -131,7 +130,7 @@ public final class IndexUtils {
@NotNull String[] propertyNames,
@NotNull String... declaringNodeTypeNames) throws RepositoryException {
- return createIndexDefinition(indexNode, indexDefName, unique, ImmutableList.copyOf(propertyNames), ImmutableList.copyOf(declaringNodeTypeNames), PropertyIndexEditorProvider.TYPE, null);
+ return createIndexDefinition(indexNode, indexDefName, unique, CollectionUtils.toImmutableList(propertyNames), CollectionUtils.toImmutableList(declaringNodeTypeNames), PropertyIndexEditorProvider.TYPE, null);
}
/**
diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/inventory/IndexPrinter.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/inventory/IndexPrinter.java
index 2ccabd43af..853992fd7f 100644
--- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/inventory/IndexPrinter.java
+++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/inventory/IndexPrinter.java
@@ -28,11 +28,11 @@ import java.util.TimeZone;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.felix.inventory.Format;
import org.apache.felix.inventory.InventoryPrinter;
import org.apache.jackrabbit.oak.api.jmx.IndexStatsMBean;
import org.apache.jackrabbit.oak.commons.IOUtils;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.commons.json.JsopBuilder;
import org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfo;
import org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoService;
@@ -76,7 +76,7 @@ public class IndexPrinter implements InventoryPrinter {
}
private void asyncLanesInfo(PrinterOutput po) {
- List<String> asyncLanes = ImmutableList.copyOf(asyncIndexInfoService.getAsyncLanes());
+ List<String> asyncLanes = CollectionUtils.toImmutableList(asyncIndexInfoService.getAsyncLanes());
po.startSection("Async Indexers State", true);
po.text("Number of async indexer lanes", asyncLanes.size());
diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java
index 0e3766cf2a..fa3fbdedf0 100644
--- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java
+++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java
@@ -436,7 +436,7 @@ public class ReadWriteVersionManager extends ReadOnlyVersionManager {
Validate.checkState(versionable.hasProperty(JCR_PREDECESSORS));
PropertyState state = versionable.getProperty(JCR_PREDECESSORS);
- List<String> predecessors = ImmutableList.copyOf(state.getValue(Type.REFERENCES));
+ List<String> predecessors = CollectionUtils.toImmutableList(state.getValue(Type.REFERENCES));
NodeBuilder version = vHistory.child(calculateVersion(vHistory, versionable));
String versionUUID = UUIDUtils.generateUUID();
diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexDefinitionUpdaterTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexDefinitionUpdaterTest.java
index 2ace0da3ad..5a3e49db76 100644
--- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexDefinitionUpdaterTest.java
+++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexDefinitionUpdaterTest.java
@@ -27,12 +27,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.felix.inventory.Format;
import org.apache.jackrabbit.oak.api.CommitFailedException;
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.CollectionUtils;
import org.apache.jackrabbit.oak.plugins.index.inventory.IndexDefinitionPrinter;
import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore;
import org.apache.jackrabbit.oak.plugins.tree.factories.TreeFactory;
@@ -144,7 +144,7 @@ public class IndexDefinitionUpdaterTest {
NodeBuilder idxBuilder = updater.apply(builder, "/oak:index/barIndex");
PropertyState childOrder = builder.getChildNode("oak:index").getProperty(":childOrder");
- List<String> names = ImmutableList.copyOf(childOrder.getValue(Type.NAMES));
+ List<String> names = CollectionUtils.toImmutableList(childOrder.getValue(Type.NAMES));
assertEquals(asList("fooIndex", "barIndex"), names);
diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/ContentMirrorStoreStrategyTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/ContentMirrorStoreStrategyTest.java
index f00db7a58b..0999562341 100644
--- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/ContentMirrorStoreStrategyTest.java
+++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/ContentMirrorStoreStrategyTest.java
@@ -17,7 +17,6 @@
package org.apache.jackrabbit.oak.plugins.index.property.strategy;
import static org.apache.jackrabbit.guava.common.base.Suppliers.memoize;
-import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf;
import static java.util.Arrays.asList;
import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.ENTRY_COUNT_PROPERTY_NAME;
import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_CONTENT_NODE_NAME;
@@ -37,6 +36,7 @@ import java.util.function.Supplier;
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.query.index.FilterImpl;
import org.apache.jackrabbit.oak.spi.query.Filter;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -306,21 +306,21 @@ public class ContentMirrorStoreStrategyTest {
indexMeta.setChildNode(INDEX_CONTENT_NODE_NAME, builder.getNodeState());
Iterable<String> paths = store.query(filter, null, indexMeta.getNodeState(), KEY);
- assertThat(copyOf(paths), containsInAnyOrder("a", "a/c", "b"));
+ assertThat(CollectionUtils.toImmutableList(paths), containsInAnyOrder("a", "a/c", "b"));
FilterImpl filter2 = FilterImpl.newTestInstance();
filter2.restrictPath("/content/a", Filter.PathRestriction.ALL_CHILDREN);
paths = store.query(filter2, null, indexMeta.getNodeState(), KEY);
- assertThat(copyOf(paths), containsInAnyOrder("a", "a/c"));
+ assertThat(CollectionUtils.toImmutableList(paths), containsInAnyOrder("a", "a/c"));
store = new ContentMirrorStoreStrategy(INDEX_CONTENT_NODE_NAME, "/content", true);
paths = store.query(filter, null, indexMeta.getNodeState(), KEY);
- assertThat(copyOf(paths), containsInAnyOrder("/content/a", "/content/a/c", "/content/b"));
+ assertThat(CollectionUtils.toImmutableList(paths), containsInAnyOrder("/content/a", "/content/a/c", "/content/b"));
paths = store.query(filter2, null, indexMeta.getNodeState(), KEY);
- assertThat(copyOf(paths), containsInAnyOrder("/content/a", "/content/a/c"));
+ assertThat(CollectionUtils.toImmutableList(paths), containsInAnyOrder("/content/a", "/content/a/c"));
}
private static void assertInRange(String msg, double expected, double actual) {
diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/TraversalAvoidanceTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/TraversalAvoidanceTest.java
index fc39b40057..8ae5ea8186 100644
--- a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/TraversalAvoidanceTest.java
+++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/TraversalAvoidanceTest.java
@@ -25,6 +25,7 @@ import org.apache.jackrabbit.oak.Oak;
import org.apache.jackrabbit.oak.api.ContentRepository;
import org.apache.jackrabbit.oak.api.Result;
import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate;
import org.apache.jackrabbit.oak.plugins.index.counter.NodeCounterEditorProvider;
import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore;
@@ -248,7 +249,7 @@ public class TraversalAvoidanceTest extends AbstractQueryTest {
@Override
public List<IndexPlan> getPlans(Filter filter, List<OrderEntry> sortOrder, NodeState rootState) {
- return ImmutableList.copyOf(plans);
+ return CollectionUtils.toImmutableList(plans);
}
@Override
diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlValidatorTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlValidatorTest.java
index 221488a86c..f43ee5ff43 100644
--- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlValidatorTest.java
+++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlValidatorTest.java
@@ -28,6 +28,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.CollectionUtils;
import org.apache.jackrabbit.oak.namepath.NamePathMapper;
import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore;
import org.apache.jackrabbit.oak.plugins.tree.TreeProvider;
@@ -163,7 +164,7 @@ public class AccessControlValidatorTest extends AbstractSecurityTest implements
private static Tree createACE(@NotNull Tree acl, @NotNull String aceName, @NotNull String ntName, @NotNull String principalName, @NotNull String... privilegeNames) throws AccessDeniedException {
Tree ace = TreeUtil.addChild(acl, aceName, ntName);
ace.setProperty(REP_PRINCIPAL_NAME, principalName);
- ace.setProperty(REP_PRIVILEGES, ImmutableList.copyOf(privilegeNames), Type.NAMES);
+ ace.setProperty(REP_PRIVILEGES, CollectionUtils.toImmutableList(privilegeNames), Type.NAMES);
return ace;
}
diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeAccessControlManagerTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeAccessControlManagerTest.java
index ae9cab531a..c1ddb08112 100644
--- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeAccessControlManagerTest.java
+++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeAccessControlManagerTest.java
@@ -101,7 +101,7 @@ public class CompositeAccessControlManagerTest extends AbstractSecurityTest {
@NotNull
private CompositeAccessControlManager createComposite(@NotNull AggregationFilter aggregationFilter, @NotNull AccessControlManager... acMgrs) {
- return new CompositeAccessControlManager(root, NamePathMapper.DEFAULT, getSecurityProvider(), ImmutableList.copyOf(acMgrs), aggregationFilter);
+ return new CompositeAccessControlManager(root, NamePathMapper.DEFAULT, getSecurityProvider(), CollectionUtils.toImmutableList(acMgrs), aggregationFilter);
}
@Test
diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderFullScopeTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderFullScopeTest.java
index ead95d6ab8..afee969202 100644
--- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderFullScopeTest.java
+++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderFullScopeTest.java
@@ -22,10 +22,10 @@ import java.util.Set;
import javax.jcr.Session;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.api.JackrabbitSession;
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.plugins.tree.TreeLocation;
import org.apache.jackrabbit.oak.spi.security.authorization.permission.AggregatedPermissionProvider;
import org.apache.jackrabbit.oak.spi.security.authorization.permission.Permissions;
@@ -226,7 +226,7 @@ public class CompositeProviderFullScopeTest extends AbstractCompositeProviderTes
for (String p : defActionsGranted.keySet()) {
String[] actions = defActionsGranted.get(p);
- if (ImmutableList.copyOf(actions).contains(Session.ACTION_READ)) {
+ if (CollectionUtils.toImmutableList(actions).contains(Session.ACTION_READ)) {
TreeLocation tl = TreeLocation.create(readOnlyRoot, p);
assertEquals(p, tl.getTree() != null, cppTestUser.isGranted(p, Session.ACTION_READ));
} else {
diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderGetTreePermissionTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderGetTreePermissionTest.java
index 001bc1993b..6a7785b4c6 100644
--- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderGetTreePermissionTest.java
+++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderGetTreePermissionTest.java
@@ -16,11 +16,11 @@
*/
package org.apache.jackrabbit.oak.security.authorization.composite;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.oak.AbstractSecurityTest;
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.plugins.tree.TreeType;
import org.apache.jackrabbit.oak.plugins.tree.TreeTypeProvider;
import org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants;
@@ -47,7 +47,7 @@ public class CompositeProviderGetTreePermissionTest extends AbstractSecurityTest
private CompositePermissionProvider createProvider(@NotNull CompositeAuthorizationConfiguration.CompositionType compositionType,
@NotNull AggregatedPermissionProvider... providers) {
- return CompositePermissionProvider.create(root, ImmutableList.copyOf(providers), Context.DEFAULT, compositionType, getRootProvider(), getTreeProvider());
+ return CompositePermissionProvider.create(root, CollectionUtils.toImmutableList(providers), Context.DEFAULT, compositionType, getRootProvider(), getTreeProvider());
}
@Test
diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderSupportedTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderSupportedTest.java
index e3db40fd88..24ac8df7bb 100644
--- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderSupportedTest.java
+++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderSupportedTest.java
@@ -16,12 +16,12 @@
*/
package org.apache.jackrabbit.oak.security.authorization.composite;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.oak.AbstractSecurityTest;
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.PathUtils;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
import org.apache.jackrabbit.oak.plugins.tree.TreeLocation;
import org.apache.jackrabbit.oak.spi.security.Context;
@@ -89,7 +89,7 @@ public class CompositeProviderSupportedTest extends AbstractSecurityTest {
}
private CompositePermissionProvider createProvider(@NotNull CompositeAuthorizationConfiguration.CompositionType compositionType, @NotNull AggregatedPermissionProvider... aggregated) {
- return CompositePermissionProvider.create(root, ImmutableList.copyOf(aggregated), Context.DEFAULT, compositionType, getRootProvider(), getTreeProvider());
+ return CompositePermissionProvider.create(root, CollectionUtils.toImmutableList(aggregated), Context.DEFAULT, compositionType, getRootProvider(), getTreeProvider());
}
@Test
diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/ChildOrderDiffTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/ChildOrderDiffTest.java
index 0db13cbfbb..9b9f261094 100644
--- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/ChildOrderDiffTest.java
+++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/ChildOrderDiffTest.java
@@ -16,9 +16,9 @@
*/
package org.apache.jackrabbit.oak.security.authorization.permission;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
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.plugins.memory.PropertyStates;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
@@ -30,7 +30,7 @@ public class ChildOrderDiffTest {
@NotNull
private static PropertyState createPropertyState(@NotNull String... names) {
- return PropertyStates.createProperty("any", ImmutableList.copyOf(names), Type.NAMES);
+ return PropertyStates.createProperty("any", CollectionUtils.toImmutableList(names), Type.NAMES);
}
@Test
diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AddMembersByIdBestEffortTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AddMembersByIdBestEffortTest.java
index c4c16a8513..cc5fd8797e 100644
--- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AddMembersByIdBestEffortTest.java
+++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AddMembersByIdBestEffortTest.java
@@ -21,13 +21,13 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.guava.common.collect.Iterators;
import org.apache.jackrabbit.api.security.user.Authorizable;
import org.apache.jackrabbit.api.security.user.Group;
import org.apache.jackrabbit.api.security.user.UserManager;
import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal;
import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration;
@@ -110,7 +110,7 @@ public class AddMembersByIdBestEffortTest extends AbstractAddMembersByIdTest {
assertTrue(failed.isEmpty());
Iterable<String> memberIds = getMemberIds(testGroup);
- Iterables.elementsEqual(ImmutableList.copyOf(NON_EXISTING_IDS), memberIds);
+ Iterables.elementsEqual(CollectionUtils.toImmutableList(NON_EXISTING_IDS), memberIds);
Iterator<Authorizable> members = testGroup.getDeclaredMembers();
assertFalse(members.hasNext());
diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/PasswordHistoryTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/PasswordHistoryTest.java
index d2c31065a1..4c9d296803 100644
--- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/PasswordHistoryTest.java
+++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/PasswordHistoryTest.java
@@ -29,6 +29,7 @@ import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.api.security.user.User;
import org.apache.jackrabbit.oak.AbstractSecurityTest;
import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration;
import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
@@ -62,7 +63,9 @@ public class PasswordHistoryTest extends AbstractSecurityTest implements UserCon
@NotNull
private List<String> getHistory(@NotNull User user) throws RepositoryException {
Iterable<String> history = TreeUtil.getStrings(root.getTree(user.getPath()).getChild(REP_PWD), REP_PWD_HISTORY);
- return (history == null) ? Collections.emptyList() : ImmutableList.copyOf(history).reverse();
+ final List<String> historyList = (history == null) ? Collections.emptyList() : CollectionUtils.toList(history);
+ Collections.reverse(historyList);
+ return CollectionUtils.toImmutableList(historyList);
}
/**
diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipIgnoreTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipIgnoreTest.java
index d154b00c27..5cdb40356f 100644
--- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipIgnoreTest.java
+++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipIgnoreTest.java
@@ -28,6 +28,7 @@ import org.apache.jackrabbit.api.security.user.Group;
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.CollectionUtils;
import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal;
import org.junit.Test;
@@ -165,7 +166,7 @@ public class UserImporterMembershipIgnoreTest extends UserImporterBaseTest {
PropertyState members = groupTree.getProperty(REP_MEMBERS);
assertNotNull(members);
- assertEquals(ImmutableList.of(contentId), ImmutableList.copyOf(members.getValue(Type.STRINGS)));
+ assertEquals(ImmutableList.of(contentId), CollectionUtils.toImmutableList(members.getValue(Type.STRINGS)));
}
@Test
@@ -180,7 +181,7 @@ public class UserImporterMembershipIgnoreTest extends UserImporterBaseTest {
PropertyState members = groupTree.getProperty(REP_MEMBERS);
assertNotNull(members);
- assertEquals(ImmutableList.of(contentId), ImmutableList.copyOf(members.getValue(Type.STRINGS)));
+ assertEquals(ImmutableList.of(contentId), CollectionUtils.toImmutableList(members.getValue(Type.STRINGS)));
}
@Test
@@ -209,7 +210,7 @@ public class UserImporterMembershipIgnoreTest extends UserImporterBaseTest {
PropertyState members = groupTree.getProperty(REP_MEMBERS);
assertNotNull(members);
- assertEquals(ImmutableList.of(knownMemberContentId), ImmutableList.copyOf(members.getValue(Type.STRINGS)));
+ assertEquals(ImmutableList.of(knownMemberContentId), CollectionUtils.toImmutableList(members.getValue(Type.STRINGS)));
}
@Test
@@ -227,6 +228,6 @@ public class UserImporterMembershipIgnoreTest extends UserImporterBaseTest {
PropertyState members = groupTree.getProperty(REP_MEMBERS);
assertNotNull(members);
- assertEquals(ImmutableList.of(contentId), ImmutableList.copyOf(members.getValue(Type.STRINGS)));
+ assertEquals(ImmutableList.of(contentId), CollectionUtils.toImmutableList(members.getValue(Type.STRINGS)));
}
}
\ No newline at end of file
diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManagerTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManagerTest.java
index 4af97d3088..de683762c0 100644
--- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManagerTest.java
+++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManagerTest.java
@@ -28,6 +28,7 @@ import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils
import org.apache.jackrabbit.oak.api.ContentSession;
import org.apache.jackrabbit.oak.api.Root;
import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.query.QueryEngineSettings;
import org.apache.jackrabbit.oak.security.internal.SecurityProviderBuilder;
import org.apache.jackrabbit.oak.security.user.AbstractUserTest;
@@ -495,7 +496,7 @@ public class UserQueryManagerTest extends AbstractUserTest {
};
Iterator<Authorizable> result = queryMgr.findAuthorizables(q);
- assertEquals(ImmutableList.of(user, g2, g), ImmutableList.copyOf(result));
+ assertEquals(ImmutableList.of(user, g2, g), CollectionUtils.toImmutableList(result));
}
@Test
@@ -516,7 +517,7 @@ public class UserQueryManagerTest extends AbstractUserTest {
};
Iterator<Authorizable> result = queryMgr.findAuthorizables(q);
- assertEquals(ImmutableList.of(user, g, g2), ImmutableList.copyOf(result));
+ assertEquals(ImmutableList.of(user, g, g2), CollectionUtils.toImmutableList(result));
}
@Test
diff --git a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexAugmentorFactory.java b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexAugmentorFactory.java
index b74cbf5433..8f3c5612ab 100644
--- a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexAugmentorFactory.java
+++ b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexAugmentorFactory.java
@@ -178,7 +178,7 @@ public class IndexAugmentorFactory {
CompositeIndexFieldProvider(String nodeType, List<IndexFieldProvider> providers) {
this.nodeType = nodeType;
- this.providers = ImmutableList.copyOf(providers);
+ this.providers = CollectionUtils.toImmutableList(providers);
}
@NotNull
@@ -212,7 +212,7 @@ public class IndexAugmentorFactory {
CompositeFulltextQueryTermsProvider(String nodeType, List<FulltextQueryTermsProvider> providers) {
this.nodeType = nodeType;
- this.providers = ImmutableList.copyOf(providers);
+ this.providers = CollectionUtils.toImmutableList(providers);
}
@Override
diff --git a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/NRTIndex.java b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/NRTIndex.java
index 0791004a36..a6b4de7229 100644
--- a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/NRTIndex.java
+++ b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/NRTIndex.java
@@ -29,8 +29,8 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.commons.io.FileUtils;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.commons.conditions.Validate;
import org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier;
import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexDefinition;
@@ -173,7 +173,7 @@ public class NRTIndex implements Closeable {
decrementReaderUseCount(readers);
dirReader = latestReader;
- readers = ImmutableList.copyOf(newReaders);
+ readers = CollectionUtils.toImmutableList(newReaders);
return readers;
}
diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
index 69c093c81c..6da6d7577e 100644
--- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
+++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.oak.plugins.index.lucene;
-import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf;
import static org.apache.jackrabbit.guava.common.collect.Iterators.transform;
import static org.apache.jackrabbit.guava.common.util.concurrent.MoreExecutors.newDirectExecutorService;
import static java.util.Arrays.asList;
@@ -69,6 +68,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.jackrabbit.oak.api.Blob;
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.commons.junit.LogCustomizer;
import org.apache.jackrabbit.oak.plugins.index.IndexConstants;
import org.apache.jackrabbit.oak.plugins.index.IndexUpdate;
@@ -218,7 +218,7 @@ public class LuceneIndexTest {
List<IndexPlan> plans = queryIndex.getPlans(filter, null, indexed);
Cursor cursor = queryIndex.query(plans.get(0), indexed);
- List<String> paths = copyOf(transform(cursor, IndexRow::getPath));
+ List<String> paths = CollectionUtils.toImmutableList(transform(cursor, IndexRow::getPath));
assertFalse(paths.isEmpty());
assertEquals(LuceneIndex.LUCENE_QUERY_BATCH_SIZE + 1, paths.size());
}
diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/BucketSwitcherTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/BucketSwitcherTest.java
index 3ddf24a5e3..3cf522df6f 100644
--- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/BucketSwitcherTest.java
+++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/BucketSwitcherTest.java
@@ -19,12 +19,12 @@
package org.apache.jackrabbit.oak.plugins.index.lucene.property;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.spi.state.EqualsDiff;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
import org.apache.jackrabbit.oak.spi.state.NodeState;
import org.junit.Test;
-import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf;
import static org.apache.jackrabbit.oak.plugins.index.lucene.property.HybridPropertyIndexUtil.PROP_HEAD_BUCKET;
import static org.apache.jackrabbit.oak.plugins.index.lucene.property.HybridPropertyIndexUtil.PROP_PREVIOUS_BUCKET;
import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
@@ -43,7 +43,7 @@ public class BucketSwitcherTest {
@Test
public void basic() throws Exception {
bs.switchBucket(100);
- assertThat(copyOf(bs.getOldBuckets()), empty());
+ assertThat(CollectionUtils.toImmutableList(bs.getOldBuckets()), empty());
}
@Test
@@ -52,7 +52,7 @@ public class BucketSwitcherTest {
builder.setProperty(PROP_HEAD_BUCKET, "1");
bs.switchBucket(100);
- assertThat(copyOf(bs.getOldBuckets()), empty());
+ assertThat(CollectionUtils.toImmutableList(bs.getOldBuckets()), empty());
}
@Test
@@ -65,7 +65,7 @@ public class BucketSwitcherTest {
bs.switchBucket(100);
assertFalse(builder.hasProperty(PROP_PREVIOUS_BUCKET));
assertEquals("2", builder.getString(PROP_HEAD_BUCKET));
- assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1"));
+ assertThat(CollectionUtils.toImmutableList(bs.getOldBuckets()), containsInAnyOrder("1"));
}
@Test
@@ -81,7 +81,7 @@ public class BucketSwitcherTest {
assertEquals("3", builder.getString(PROP_HEAD_BUCKET));
assertTrue(builder.hasChildNode("3"));
- assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1"));
+ assertThat(CollectionUtils.toImmutableList(bs.getOldBuckets()), containsInAnyOrder("1"));
}
@Test
@@ -96,7 +96,7 @@ public class BucketSwitcherTest {
bs.switchBucket(150);
assertFalse(builder.hasProperty(PROP_PREVIOUS_BUCKET));
assertEquals("3", builder.getString(PROP_HEAD_BUCKET));
- assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1", "2"));
+ assertThat(CollectionUtils.toImmutableList(bs.getOldBuckets()), containsInAnyOrder("1", "2"));
}
/**
@@ -117,7 +117,7 @@ public class BucketSwitcherTest {
assertEquals("3", builder.getString(PROP_HEAD_BUCKET));
assertEquals("2", builder.getString(PROP_PREVIOUS_BUCKET));
- assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1"));
+ assertThat(CollectionUtils.toImmutableList(bs.getOldBuckets()), containsInAnyOrder("1"));
NodeState state1 = builder.getNodeState();
assertFalse(bs.switchBucket(100));
@@ -126,7 +126,7 @@ public class BucketSwitcherTest {
//as previous
assertEquals("3", builder.getString(PROP_HEAD_BUCKET));
assertEquals("2", builder.getString(PROP_PREVIOUS_BUCKET));
- assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1"));
+ assertThat(CollectionUtils.toImmutableList(bs.getOldBuckets()), containsInAnyOrder("1"));
NodeState state2 = builder.getNodeState();
assertFalse(bs.switchBucket(100));
@@ -134,7 +134,7 @@ public class BucketSwitcherTest {
//Async indexer time still not changed. So head bucket remains same
assertEquals("3", builder.getString(PROP_HEAD_BUCKET));
assertEquals("2", builder.getString(PROP_PREVIOUS_BUCKET));
- assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1"));
+ assertThat(CollectionUtils.toImmutableList(bs.getOldBuckets()), containsInAnyOrder("1"));
NodeState state3 = builder.getNodeState();
@@ -159,7 +159,7 @@ public class BucketSwitcherTest {
assertEquals("3", builder.getString(PROP_HEAD_BUCKET));
assertEquals("2", builder.getString(PROP_PREVIOUS_BUCKET));
- assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1"));
+ assertThat(CollectionUtils.toImmutableList(bs.getOldBuckets()), containsInAnyOrder("1"));
NodeState state1 = builder.getNodeState();
assertTrue(bs.switchBucket(150));
@@ -167,14 +167,14 @@ public class BucketSwitcherTest {
//This time previous bucket should be discarded
assertEquals("3", builder.getString(PROP_HEAD_BUCKET));
assertNull(builder.getString(PROP_PREVIOUS_BUCKET));
- assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1", "2"));
+ assertThat(CollectionUtils.toImmutableList(bs.getOldBuckets()), containsInAnyOrder("1", "2"));
NodeState state2 = builder.getNodeState();
assertTrue(bs.switchBucket(200));
assertEquals("3", builder.getString(PROP_HEAD_BUCKET));
assertNull(builder.getString(PROP_PREVIOUS_BUCKET));
- assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1", "2"));
+ assertThat(CollectionUtils.toImmutableList(bs.getOldBuckets()), containsInAnyOrder("1", "2"));
//assert no change done after previous is removed
//not even change of asyncIndexedTo
diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexLookupTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexLookupTest.java
index 1ee37ff43f..46fc78ee9e 100644
--- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexLookupTest.java
+++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexLookupTest.java
@@ -21,8 +21,8 @@ package org.apache.jackrabbit.oak.plugins.index.lucene.property;
import java.util.List;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder;
import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition;
import org.apache.jackrabbit.oak.plugins.index.search.PropertyDefinition;
@@ -108,7 +108,7 @@ public class HybridPropertyIndexLookupTest {
Iterable<String> paths = lookup.query(filter, propertyName,
filter.getPropertyRestriction(propertyName));
- assertThat(ImmutableList.copyOf(paths), containsInAnyOrder("/a"));
+ assertThat(CollectionUtils.toImmutableList(paths), containsInAnyOrder("/a"));
}
@Test
@@ -128,14 +128,14 @@ public class HybridPropertyIndexLookupTest {
Iterable<String> paths = lookup.query(filter, propertyName,
filter.getPropertyRestriction(propertyName));
- assertThat(ImmutableList.copyOf(paths), containsInAnyOrder("/a"));
+ assertThat(CollectionUtils.toImmutableList(paths), containsInAnyOrder("/a"));
lookup = new HybridPropertyIndexLookup(indexPath, builder.getNodeState(),
"/content", true);
paths = lookup.query(filter, propertyName,
filter.getPropertyRestriction(propertyName));
- assertThat(ImmutableList.copyOf(paths), containsInAnyOrder("/content/a"));
+ assertThat(CollectionUtils.toImmutableList(paths), containsInAnyOrder("/content/a"));
}
private void propertyUpdated(String nodePath, String propertyRelativeName, String value){
@@ -157,7 +157,7 @@ public class HybridPropertyIndexLookupTest {
HybridPropertyIndexLookup lookup = new HybridPropertyIndexLookup(indexPath, builder.getNodeState());
Iterable<String> paths = lookup.query(filter, propertyName,
filter.getPropertyRestriction(propertyRestrictionName));
- return ImmutableList.copyOf(paths);
+ return CollectionUtils.toImmutableList(paths);
}
private PropertyDefinition pd(String propName){
diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexStorageTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexStorageTest.java
index e292ac1aa2..f0a350ffe8 100644
--- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexStorageTest.java
+++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexStorageTest.java
@@ -21,8 +21,8 @@ package org.apache.jackrabbit.oak.plugins.index.lucene.property;
import java.util.List;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.oak.api.PropertyValue;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder;
import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition;
import org.apache.jackrabbit.oak.plugins.index.search.PropertyDefinition;
@@ -205,7 +205,7 @@ public class HybridPropertyIndexStorageTest {
HybridPropertyIndexLookup lookup = new HybridPropertyIndexLookup(indexPath, builder.getNodeState());
FilterImpl filter = createFilter(root, "nt:base");
Iterable<String> paths = lookup.query(filter, propertyName, value);
- return ImmutableList.copyOf(paths);
+ return CollectionUtils.toImmutableList(paths);
}
private PropertyIndexUpdateCallback newCallback(){
diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/PropertyIndexCleanerTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/PropertyIndexCleanerTest.java
index b8b89933bb..cb0d85cbbd 100644
--- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/PropertyIndexCleanerTest.java
+++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/PropertyIndexCleanerTest.java
@@ -24,9 +24,9 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.oak.InitialContent;
import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfo;
import org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoService;
import org.apache.jackrabbit.oak.plugins.index.lucene.property.PropertyIndexCleaner.CleanupStats;
@@ -332,7 +332,7 @@ public class PropertyIndexCleanerTest {
HybridPropertyIndexLookup lookup = new HybridPropertyIndexLookup(indexPath, getNode(root, indexPath));
FilterImpl filter = FilterImpl.newTestInstance();
Iterable<String> paths = lookup.query(filter, propertyName, PropertyValues.newString(value));
- return ImmutableList.copyOf(paths);
+ return CollectionUtils.toImmutableList(paths);
}
private static class SimpleAsyncInfoService implements AsyncIndexInfoService {
diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/UniqueIndexCleanerTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/UniqueIndexCleanerTest.java
index 9b33ff2e4f..7e8a05a9d4 100644
--- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/UniqueIndexCleanerTest.java
+++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/UniqueIndexCleanerTest.java
@@ -20,10 +20,10 @@
package org.apache.jackrabbit.oak.plugins.index.lucene.property;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
import org.junit.Test;
-import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.jackrabbit.oak.plugins.index.lucene.property.HybridPropertyIndexUtil.PROP_CREATED;
import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
@@ -42,7 +42,7 @@ public class UniqueIndexCleanerTest {
UniqueIndexCleaner cleaner = new UniqueIndexCleaner(MILLISECONDS, 1);
cleaner.clean(builder, 10);
- assertThat(copyOf(builder.getChildNodeNames()), containsInAnyOrder("a", "b"));
+ assertThat(CollectionUtils.toImmutableList(builder.getChildNodeNames()), containsInAnyOrder("a", "b"));
}
@Test
@@ -53,7 +53,7 @@ public class UniqueIndexCleanerTest {
refresh();
UniqueIndexCleaner cleaner = new UniqueIndexCleaner(MILLISECONDS, 100);
cleaner.clean(builder, 200);
- assertThat(copyOf(builder.getChildNodeNames()), containsInAnyOrder("b"));
+ assertThat(CollectionUtils.toImmutableList(builder.getChildNodeNames()), containsInAnyOrder("b"));
}
private void refresh(){
diff --git a/oak-query-spi/src/main/java/org/apache/jackrabbit/oak/spi/query/CompositeQueryIndexProvider.java b/oak-query-spi/src/main/java/org/apache/jackrabbit/oak/spi/query/CompositeQueryIndexProvider.java
index 57e70fe08a..5671e9c5aa 100644
--- a/oak-query-spi/src/main/java/org/apache/jackrabbit/oak/spi/query/CompositeQueryIndexProvider.java
+++ b/oak-query-spi/src/main/java/org/apache/jackrabbit/oak/spi/query/CompositeQueryIndexProvider.java
@@ -21,6 +21,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.List;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.spi.state.NodeState;
import org.jetbrains.annotations.NotNull;
@@ -56,7 +57,7 @@ public class CompositeQueryIndexProvider implements QueryIndexProvider {
return providers.iterator().next();
} else {
return new CompositeQueryIndexProvider(
- ImmutableList.copyOf(providers));
+ CollectionUtils.toImmutableList(providers));
}
}
diff --git a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/SimpleFlatFileUtil.java b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/SimpleFlatFileUtil.java
index 5c54bc6548..39082cf702 100644
--- a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/SimpleFlatFileUtil.java
+++ b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/SimpleFlatFileUtil.java
@@ -18,7 +18,6 @@
*/
package org.apache.jackrabbit.oak.index.indexer.document.flatfile;
-import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf;
import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
import java.io.BufferedWriter;
@@ -29,6 +28,7 @@ import java.nio.file.Files;
import java.util.Comparator;
import java.util.stream.StreamSupport;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry;
import org.apache.jackrabbit.oak.plugins.document.DocumentNodeState;
import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
@@ -93,7 +93,7 @@ public class SimpleFlatFileUtil {
return;
}
String jsonText = entryWriter.asSortedJson(e.getNodeState());
- String line = entryWriter.toString(copyOf(elements(path)), jsonText);
+ String line = entryWriter.toString(CollectionUtils.toImmutableList(elements(path)), jsonText);
writer.append(line);
writer.append(LINE_SEPARATOR);
totalLines++;
diff --git a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/SimpleNodeStateHolder.java b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/SimpleNodeStateHolder.java
index dd0a365c5f..6260f9bfa3 100644
--- a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/SimpleNodeStateHolder.java
+++ b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/SimpleNodeStateHolder.java
@@ -22,8 +22,8 @@ package org.apache.jackrabbit.oak.index.indexer.document.flatfile;
import java.util.List;
import org.apache.jackrabbit.oak.commons.StringUtils;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
-import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf;
import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
import static org.apache.jackrabbit.oak.index.indexer.document.flatfile.NodeStateEntryWriter.getPath;
@@ -32,7 +32,7 @@ public class SimpleNodeStateHolder implements NodeStateHolder{
private final List<String> pathElements;
public SimpleNodeStateHolder(String line) {
- this.pathElements = copyOf(elements(getPath(line)));
+ this.pathElements = CollectionUtils.toImmutableList(elements(getPath(line)));
this.line = line;
}
diff --git a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/StateInBytesHolder.java b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/StateInBytesHolder.java
index 3b46e85ba8..f694b0715d 100644
--- a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/StateInBytesHolder.java
+++ b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/StateInBytesHolder.java
@@ -23,8 +23,8 @@ import java.nio.charset.StandardCharsets;
import java.util.List;
import org.apache.jackrabbit.oak.commons.StringUtils;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
-import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf;
import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
class StateInBytesHolder implements NodeStateHolder {
@@ -32,7 +32,7 @@ class StateInBytesHolder implements NodeStateHolder {
private final byte[] content;
public StateInBytesHolder(String path, String line) {
- this.pathElements = copyOf(elements(path));
+ this.pathElements = CollectionUtils.toImmutableList(elements(path));
this.content = line.getBytes(StandardCharsets.UTF_8);
}
diff --git a/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/ChildNodeStateProviderTest.java b/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/ChildNodeStateProviderTest.java
index 59f829c4a5..6faf6a0f48 100644
--- a/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/ChildNodeStateProviderTest.java
+++ b/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/ChildNodeStateProviderTest.java
@@ -26,11 +26,11 @@ import java.util.Set;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.guava.common.collect.Iterators;
import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry;
import org.apache.jackrabbit.oak.spi.state.NodeState;
import org.junit.Test;
-import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
@@ -60,17 +60,17 @@ public class ChildNodeStateProviderTest {
CountingIterable<NodeStateEntry> citr = createList(preferred, asList("/a", "/a/jcr:content", "/a/c", "/a/d", "/e", "/e/f", "/g", "/h"));
ChildNodeStateProvider p = new ChildNodeStateProvider(citr, "/a", preferred);
- assertEquals(asList("jcr:content", "c", "d"), copyOf(childNames(p.children())));
+ assertEquals(asList("jcr:content", "c", "d"), CollectionUtils.toImmutableList(childNames(p.children())));
assertEquals(5, citr.getCount());
citr.reset();
p = new ChildNodeStateProvider(citr, "/e", preferred);
- assertEquals(singletonList("f"), copyOf(childNames(p.children())));
+ assertEquals(singletonList("f"), CollectionUtils.toImmutableList(childNames(p.children())));
assertEquals(7, citr.getCount());
p = new ChildNodeStateProvider(citr, "/g", preferred);
- assertEquals(emptyList(), copyOf(childNames(p.children())));
+ assertEquals(emptyList(), CollectionUtils.toImmutableList(childNames(p.children())));
}
@Test
@@ -79,22 +79,22 @@ public class ChildNodeStateProviderTest {
CountingIterable<NodeStateEntry> citr = createList(preferred, asList("/a", "/a/b", "/a/b/c", "/a/b/c/d", "/e", "/e/f", "/g", "/h"));
ChildNodeStateProvider p = new ChildNodeStateProvider(citr, "/a", preferred);
- assertEquals(singletonList("b"), copyOf(childNames(p.children())));
+ assertEquals(singletonList("b"), CollectionUtils.toImmutableList(childNames(p.children())));
assertEquals(5, citr.getCount());
citr.reset();
p = new ChildNodeStateProvider(citr, "/a/b", preferred);
- assertEquals(singletonList("c"), copyOf(childNames(p.children())));
+ assertEquals(singletonList("c"), CollectionUtils.toImmutableList(childNames(p.children())));
assertEquals(5, citr.getCount());
p = new ChildNodeStateProvider(citr, "/a/b/c", preferred);
- assertEquals(singletonList("d"), copyOf(childNames(p.children())));
+ assertEquals(singletonList("d"), CollectionUtils.toImmutableList(childNames(p.children())));
p = new ChildNodeStateProvider(citr, "/a/b/c/d", preferred);
- assertEquals(emptyList(), copyOf(childNames(p.children())));
+ assertEquals(emptyList(), CollectionUtils.toImmutableList(childNames(p.children())));
p = new ChildNodeStateProvider(citr, "/h", preferred);
- assertEquals(emptyList(), copyOf(childNames(p.children())));
+ assertEquals(emptyList(), CollectionUtils.toImmutableList(childNames(p.children())));
}
@Test
@@ -152,7 +152,7 @@ public class ChildNodeStateProviderTest {
CountingIterable<NodeStateEntry> citr = createList(preferred, asList("/a", "/a/jcr:content", "/a/c", "/a/d", "/e", "/e/f"));
ChildNodeStateProvider p = new ChildNodeStateProvider(citr, "/a", preferred);
- assertEquals(asList("jcr:content", "c", "d"), copyOf(childNames(p.children())));
+ assertEquals(asList("jcr:content", "c", "d"), CollectionUtils.toImmutableList(childNames(p.children())));
assertEquals(5, citr.getCount());
}
@@ -163,7 +163,7 @@ public class ChildNodeStateProviderTest {
"/a/c", "/a/c/status","/a/d", "/e", "/e/f"));
ChildNodeStateProvider p = new ChildNodeStateProvider(citr, "/a", preferred);
- assertEquals(asList("jcr:content", "c", "d"), copyOf(childNames(p.children())));
+ assertEquals(asList("jcr:content", "c", "d"), CollectionUtils.toImmutableList(childNames(p.children())));
assertEquals(7, citr.getCount());
}
diff --git a/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/NodeStateEntryWriterTest.java b/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/NodeStateEntryWriterTest.java
index ddfc6b1f1d..32c0192fc7 100644
--- a/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/NodeStateEntryWriterTest.java
+++ b/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/NodeStateEntryWriterTest.java
@@ -23,18 +23,16 @@ import java.util.Arrays;
import java.util.List;
import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry;
import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry.NodeStateEntryBuilder;
import org.apache.jackrabbit.oak.spi.blob.BlobStore;
import org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore;
import org.apache.jackrabbit.oak.spi.state.EqualsDiff;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
import org.junit.Test;
-import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf;
import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
-import static org.apache.jackrabbit.oak.index.indexer.document.flatfile.NodeStateEntryWriter.getPath;
import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -112,7 +110,7 @@ public class NodeStateEntryWriterTest {
NodeStateEntry e1 = new NodeStateEntryBuilder(b1.getNodeState(), "/a/b/c/d").build();
String json = nw.asJson(e1.getNodeState());
- List<String> pathElements = copyOf(elements(e1.getPath()));
+ List<String> pathElements = CollectionUtils.toImmutableList(elements(e1.getPath()));
String line = nw.toString(pathElements, json);
@@ -132,7 +130,7 @@ public class NodeStateEntryWriterTest {
NodeStateEntry e1 = new NodeStateEntryBuilder(b1.getNodeState(), "/").build();
String json = nw.asJson(e1.getNodeState());
- List<String> pathElements = copyOf(elements(e1.getPath()));
+ List<String> pathElements = CollectionUtils.toImmutableList(elements(e1.getPath()));
String line = nw.toString(pathElements, json);
@@ -154,9 +152,9 @@ public class NodeStateEntryWriterTest {
b.setProperty("foo1", "bar1");
String json2 = nw.asJson(b.getNodeState());
- String line1 = nw.toString(copyOf(elements("/")), json1);
- String line2 = nw.toString(copyOf(elements("/sub-node")), json1);
- String line3 = nw.toString(copyOf(elements("/sub-node")), json2);
+ String line1 = nw.toString(CollectionUtils.toImmutableList(elements("/")), json1);
+ String line2 = nw.toString(CollectionUtils.toImmutableList(elements("/sub-node")), json1);
+ String line3 = nw.toString(CollectionUtils.toImmutableList(elements("/sub-node")), json2);
NodeStateEntryReader nr = new NodeStateEntryReader(blobStore);
diff --git a/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/TestUtils.java b/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/TestUtils.java
index e9d5b483b5..28cdf680db 100644
--- a/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/TestUtils.java
+++ b/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/TestUtils.java
@@ -19,6 +19,7 @@
package org.apache.jackrabbit.oak.index.indexer.document.flatfile;
import org.apache.jackrabbit.guava.common.collect.Iterables;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry;
import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry.NodeStateEntryBuilder;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -29,7 +30,6 @@ import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
-import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf;
import static java.util.Collections.emptySet;
import static java.util.stream.Collectors.toList;
import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
@@ -51,7 +51,7 @@ public class TestUtils {
static List<String> sortPaths(List<String> paths, Comparator<Iterable<String>> comparator) {
List<Iterable<String>> copy = paths.stream()
- .map(p -> copyOf(elements(p)))
+ .map(p -> CollectionUtils.toImmutableList(elements(p)))
.sorted(comparator)
.collect(toList());
return copy.stream().map(e -> "/" + String.join("/", e)).collect(toList());
diff --git a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/Aggregate.java b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/Aggregate.java
index 09b72ebc3d..95677d34ca 100644
--- a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/Aggregate.java
+++ b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/Aggregate.java
@@ -28,9 +28,9 @@ import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
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.plugins.index.search.util.ConfigUtil;
import org.apache.jackrabbit.oak.plugins.memory.MemoryChildNodeEntry;
import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
@@ -343,7 +343,7 @@ public class Aggregate {
}
public boolean matches(String nodePath) {
- List<String> pathElements = ImmutableList.copyOf(PathUtils.elements(nodePath));
+ List<String> pathElements = CollectionUtils.toImmutableList(PathUtils.elements(nodePath));
if (pathElements.size() != elements.length){
return false;
}
diff --git a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/PropertyDefinition.java b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/PropertyDefinition.java
index 9310058a13..e2a9917bf5 100644
--- a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/PropertyDefinition.java
+++ b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/PropertyDefinition.java
@@ -18,7 +18,6 @@
*/
package org.apache.jackrabbit.oak.plugins.index.search;
-import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf;
import static org.apache.jackrabbit.guava.common.collect.Iterables.toArray;
import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
import static org.apache.jackrabbit.oak.commons.PathUtils.isAbsolute;
@@ -32,6 +31,7 @@ import static org.apache.jackrabbit.oak.plugins.index.search.util.ConfigUtil.get
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.CollectionUtils;
import org.apache.jackrabbit.oak.plugins.index.property.ValuePattern;
import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition.IndexingRule;
import org.apache.jackrabbit.oak.plugins.index.search.util.FunctionIndexProcessor;
@@ -42,6 +42,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.jcr.PropertyType;
+import java.util.ArrayList;
+import java.util.List;
public class PropertyDefinition {
private static final Logger log = LoggerFactory.getLogger(PropertyDefinition.class);
@@ -306,7 +308,7 @@ public class PropertyDefinition {
if (FulltextIndexConstants.REGEX_ALL_PROPS.equals(path)) {
return EMPTY_ANCESTORS;
} else {
- return toArray(copyOf(elements(PathUtils.getParentPath(path))), String.class);
+ return toArray(CollectionUtils.toImmutableList(elements(PathUtils.getParentPath(path))), String.class);
}
}
diff --git a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/CompositeConfiguration.java b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/CompositeConfiguration.java
index 64a669bb15..a289f4b739 100644
--- a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/CompositeConfiguration.java
+++ b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/CompositeConfiguration.java
@@ -144,7 +144,7 @@ public abstract class CompositeConfiguration<T extends SecurityConfiguration> im
if (configurations.isEmpty() && defaultConfig != null) {
return ImmutableList.of(defaultConfig);
} else {
- return ImmutableList.copyOf(configurations);
+ return CollectionUtils.toImmutableList(configurations);
}
}
@@ -221,20 +221,20 @@ public abstract class CompositeConfiguration<T extends SecurityConfiguration> im
public List<? extends CommitHook> getCommitHooks(@NotNull final String workspaceName) {
Iterable<CommitHook> t = Iterables.concat(Lists.transform(getConfigurations(),
securityConfiguration -> securityConfiguration.getCommitHooks(workspaceName)));
- return ImmutableList.copyOf(t);
+ return CollectionUtils.toImmutableList(t);
}
@NotNull
@Override
public List<? extends ValidatorProvider> getValidators(@NotNull final String workspaceName, @NotNull final Set<Principal> principals, @NotNull final MoveTracker moveTracker) {
Iterable<ValidatorProvider> t = Iterables.concat(Lists.transform(getConfigurations(), securityConfiguration -> securityConfiguration.getValidators(workspaceName, principals, moveTracker)));
- return ImmutableList.copyOf(t);
+ return CollectionUtils.toImmutableList(t);
}
@NotNull
@Override
public List<ThreeWayConflictHandler> getConflictHandlers() {
- return ImmutableList.copyOf(Iterables.concat(Lists.transform(getConfigurations(), securityConfiguration -> securityConfiguration.getConflictHandlers())));
+ return CollectionUtils.toImmutableList(Iterables.concat(Lists.transform(getConfigurations(), securityConfiguration -> securityConfiguration.getConflictHandlers())));
}
@NotNull
@@ -242,7 +242,7 @@ public abstract class CompositeConfiguration<T extends SecurityConfiguration> im
public List<ProtectedItemImporter> getProtectedItemImporters() {
Iterable<ProtectedItemImporter> t = Iterables.concat(Lists.transform(getConfigurations(),
securityConfiguration -> securityConfiguration.getProtectedItemImporters()));
- return ImmutableList.copyOf(t);
+ return CollectionUtils.toImmutableList(t);
}
@NotNull
diff --git a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/token/CompositeTokenProvider.java b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/token/CompositeTokenProvider.java
index 354799349e..1ffe3a57e0 100644
--- a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/token/CompositeTokenProvider.java
+++ b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/token/CompositeTokenProvider.java
@@ -21,8 +21,7 @@ import java.util.List;
import java.util.Map;
import javax.jcr.Credentials;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
-
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -35,7 +34,7 @@ public final class CompositeTokenProvider implements TokenProvider {
private final List<TokenProvider> providers;
private CompositeTokenProvider(@NotNull List<? extends TokenProvider> providers) {
- this.providers = ImmutableList.copyOf(providers);
+ this.providers = CollectionUtils.toImmutableList(providers);
}
@NotNull
diff --git a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/ImmutableACL.java b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/ImmutableACL.java
index 3c264d2a19..6afbd0eebe 100644
--- a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/ImmutableACL.java
+++ b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/ImmutableACL.java
@@ -26,8 +26,8 @@ import javax.jcr.security.AccessControlEntry;
import javax.jcr.security.AccessControlException;
import javax.jcr.security.Privilege;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.namepath.NamePathMapper;
import org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider;
import org.jetbrains.annotations.NotNull;
@@ -57,7 +57,7 @@ public class ImmutableACL extends AbstractAccessControlList {
@NotNull RestrictionProvider restrictionProvider,
@NotNull NamePathMapper namePathMapper) {
super(oakPath, namePathMapper);
- this.entries = ImmutableList.copyOf(entries);
+ this.entries = CollectionUtils.toImmutableList(entries);
this.restrictionProvider = restrictionProvider;
}
diff --git a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/xml/PropInfo.java b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/xml/PropInfo.java
index 8451aa1a55..a833bbaa72 100644
--- a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/xml/PropInfo.java
+++ b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/xml/PropInfo.java
@@ -27,6 +27,7 @@ import javax.jcr.nodetype.PropertyDefinition;
import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -100,7 +101,7 @@ public class PropInfo {
@NotNull MultipleStatus multipleStatus) {
this.name = name;
this.type = type;
- this.values = ImmutableList.copyOf(values);
+ this.values = CollectionUtils.toImmutableList(values);
this.multipleStatus = multipleStatus;
}
diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/ACETest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/ACETest.java
index bf051f79d4..2410936881 100644
--- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/ACETest.java
+++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/ACETest.java
@@ -22,6 +22,7 @@ import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry;
import org.apache.jackrabbit.api.security.authorization.PrivilegeCollection;
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.plugins.memory.PropertyStates;
import org.apache.jackrabbit.oak.plugins.value.jcr.ValueFactoryImpl;
import org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction;
@@ -105,7 +106,7 @@ public class ACETest extends AbstractAccessControlTest {
}
private Restriction createRestriction(String name, Value[] values) throws Exception {
- return new RestrictionImpl(PropertyStates.createProperty(name, ImmutableList.copyOf(values)), false);
+ return new RestrictionImpl(PropertyStates.createProperty(name, CollectionUtils.toImmutableList(values)), false);
}
@Test
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
index 039781089b..900da803e4 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
@@ -19,7 +19,6 @@ package org.apache.jackrabbit.oak.plugins.document;
import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.toSet;
import static org.apache.jackrabbit.oak.commons.conditions.Validate.checkArgument;
-import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf;
import static org.apache.jackrabbit.guava.common.collect.Iterables.filter;
import static org.apache.jackrabbit.guava.common.collect.Iterables.mergeSorted;
import static org.apache.jackrabbit.guava.common.collect.Iterables.transform;
@@ -1820,7 +1819,7 @@ public final class NodeDocument extends Document {
}
};
} else {
- changes = Iterables.concat(transform(copyOf(ranges), rangeToChanges::apply));
+ changes = Iterables.concat(transform(CollectionUtils.toImmutableList(ranges), rangeToChanges::apply));
}
return filter(changes, input -> !readRev.isRevisionNewer(input.getKey()));
}
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlorUtils.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlorUtils.java
index 2da4803dbe..20d7b35e43 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlorUtils.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlorUtils.java
@@ -27,9 +27,9 @@ import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
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.spi.state.NodeState;
import org.jetbrains.annotations.NotNull;
@@ -86,7 +86,7 @@ public final class BundlorUtils {
int expectedDepth = matcher.depth() + 1;
for (String key : keys){
- List<String> elements = ImmutableList.copyOf(PathUtils.elements(key));
+ List<String> elements = CollectionUtils.toImmutableList(PathUtils.elements(key));
int depth = elements.size() - 1;
if (depth == expectedDepth
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlor.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlor.java
index 30fbb25518..fd4ba00a22 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlor.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlor.java
@@ -25,6 +25,7 @@ import org.apache.jackrabbit.guava.common.collect.ImmutableList;
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.CollectionUtils;
import org.apache.jackrabbit.oak.spi.state.NodeState;
import static org.apache.jackrabbit.oak.commons.conditions.Validate.checkArgument;
@@ -95,7 +96,7 @@ public class DocumentBundlor {
private DocumentBundlor(List<Include> includes) {
checkArgument(!includes.isEmpty(), "Include list cannot be empty");
- this.includes = ImmutableList.copyOf(includes);
+ this.includes = CollectionUtils.toImmutableList(includes);
}
public boolean isBundled(String relativePath) {
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/Include.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/Include.java
index 5fea58f80e..e8e7d27503 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/Include.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/Include.java
@@ -22,8 +22,8 @@ package org.apache.jackrabbit.oak.plugins.document.bundlor;
import java.util.ArrayList;
import java.util.List;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import static org.apache.jackrabbit.guava.common.base.Preconditions.checkElementIndex;
@@ -53,7 +53,7 @@ public class Include {
private final String pattern;
public Include(String pattern){
- List<String> pathElements = ImmutableList.copyOf(PathUtils.elements(pattern));
+ List<String> pathElements = CollectionUtils.toImmutableList(PathUtils.elements(pattern));
List<String> elementList = new ArrayList<>(pathElements.size());
Directive directive = Directive.NONE;
for (int i = 0; i < pathElements.size(); i++) {
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreBuilder.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreBuilder.java
index d54c45d1c9..1f6f198237 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreBuilder.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreBuilder.java
@@ -22,7 +22,7 @@ package org.apache.jackrabbit.oak.plugins.document.secondary;
import java.util.Collections;
import java.util.List;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.plugins.document.NodeStateDiffer;
import org.apache.jackrabbit.oak.spi.filter.PathFilter;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
@@ -57,7 +57,7 @@ public class SecondaryStoreBuilder {
}
public SecondaryStoreBuilder metaPropNames(List<String> metaPropNames) {
- this.metaPropNames = ImmutableList.copyOf(metaPropNames);
+ this.metaPropNames = CollectionUtils.toImmutableList(metaPropNames);
return this;
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BlobReferenceIteratorTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BlobReferenceIteratorTest.java
index 55731e41ab..c6af04c7eb 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BlobReferenceIteratorTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BlobReferenceIteratorTest.java
@@ -24,10 +24,10 @@ import java.util.HashSet;
import java.util.List;
import java.util.concurrent.TimeUnit;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import com.mongodb.ReadPreference;
import org.apache.jackrabbit.oak.api.Blob;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.plugins.blob.ReferencedBlob;
import org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats;
import org.apache.jackrabbit.oak.plugins.document.mongo.MongoTestUtils;
@@ -133,7 +133,7 @@ public class BlobReferenceIteratorTest {
store.merge(b1, EmptyHook.INSTANCE, CommitInfo.EMPTY);
}
- List<ReferencedBlob> collectedBlobs = ImmutableList.copyOf(store.getReferencedBlobsIterator());
+ List<ReferencedBlob> collectedBlobs = CollectionUtils.toImmutableList(store.getReferencedBlobsIterator());
assertEquals(blobs.size(), collectedBlobs.size());
assertEquals(new HashSet<>(blobs), new HashSet<>(collectedBlobs));
}
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 8b8e72b5da..5b4e029a3e 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
@@ -49,7 +49,6 @@ import org.junit.Test;
import org.apache.jackrabbit.guava.common.collect.Iterables;
-import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf;
import static org.apache.jackrabbit.oak.plugins.document.Collection.NODES;
import static org.apache.jackrabbit.oak.plugins.document.MongoBlobGCTest.randomStream;
import static org.apache.jackrabbit.oak.plugins.document.NodeDocument.DOC_SIZE_THRESHOLD;
@@ -353,7 +352,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
}
ns.runBackgroundOperations();
NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test/foo"));
- List<NodeDocument> prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs());
+ List<NodeDocument> prevDocs = CollectionUtils.toImmutableList(doc.getAllPreviousDocs());
assertEquals(1, prevDocs.size());
assertEquals(SplitDocType.DEFAULT_LEAF, prevDocs.get(0).getSplitDocType());
}
@@ -376,7 +375,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
}
ns.runBackgroundOperations();
NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test/foo"));
- List<NodeDocument> prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs());
+ List<NodeDocument> prevDocs = CollectionUtils.toImmutableList(doc.getAllPreviousDocs());
assertEquals(1, prevDocs.size());
assertEquals(SplitDocType.COMMIT_ROOT_ONLY, prevDocs.get(0).getSplitDocType());
}
@@ -398,7 +397,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
}
ns.runBackgroundOperations();
NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test/foo"));
- List<NodeDocument> prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs());
+ List<NodeDocument> prevDocs = CollectionUtils.toImmutableList(doc.getAllPreviousDocs());
assertEquals(1, prevDocs.size());
//Check for hasBinary
@@ -451,7 +450,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
assertNotNull(doc);
assertEquals(2, doc.getPreviousRanges().size());
- List<NodeDocument> prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs());
+ List<NodeDocument> prevDocs = CollectionUtils.toImmutableList(doc.getAllPreviousDocs());
//1 intermediate and 11 previous doc
assertEquals(1 + 11, prevDocs.size());
assertTrue(prevDocs.stream().anyMatch(input -> input.getSplitDocType() == SplitDocType.INTERMEDIATE));
@@ -916,7 +915,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
NodeDocument foo = store.find(NODES, Utils.getIdFromPath("/foo"));
assertNotNull(foo);
- List<NodeDocument> prevDocs = copyOf(foo.getAllPreviousDocs());
+ List<NodeDocument> prevDocs = CollectionUtils.toImmutableList(foo.getAllPreviousDocs());
// all but most recent value are moved to individual previous docs
assertEquals(9, prevDocs.size());
}
@@ -950,7 +949,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
// now the old binary value must be moved to a previous document
foo = store.find(NODES, Utils.getIdFromPath("/foo"));
assertNotNull(foo);
- List<NodeDocument> prevDocs = copyOf(foo.getAllPreviousDocs());
+ List<NodeDocument> prevDocs = CollectionUtils.toImmutableList(foo.getAllPreviousDocs());
assertEquals(1, prevDocs.size());
}
@@ -973,7 +972,7 @@ public class DocumentSplitTest extends BaseDocumentMKTest {
NodeDocument foo = store.find(NODES, Utils.getIdFromPath("/foo"));
assertNotNull(foo);
- List<NodeDocument> prevDocs = copyOf(foo.getAllPreviousDocs());
+ List<NodeDocument> prevDocs = CollectionUtils.toImmutableList(foo.getAllPreviousDocs());
// must not create split documents for small binaries less 4k
assertEquals(0, prevDocs.size());
}
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java
index 9fc0a3a8c6..c1d473c275 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java
@@ -3070,11 +3070,11 @@ public class VersionGarbageCollectorIT {
store1.runBackgroundOperations();
List<NodeDocument> previousDocTestFoo =
- ImmutableList.copyOf(getDoc("/test/" + subNodeName).getAllPreviousDocs());
+ CollectionUtils.toImmutableList(getDoc("/test/" + subNodeName).getAllPreviousDocs());
List<NodeDocument> previousDocTestFoo2 =
- ImmutableList.copyOf(getDoc("/test2/" + subNodeName).getAllPreviousDocs());
+ CollectionUtils.toImmutableList(getDoc("/test2/" + subNodeName).getAllPreviousDocs());
List<NodeDocument> previousDocRoot =
- ImmutableList.copyOf(getDoc("/").getAllPreviousDocs());
+ CollectionUtils.toImmutableList(getDoc("/").getAllPreviousDocs());
assertEquals(1, previousDocTestFoo.size());
assertEquals(1, previousDocTestFoo2.size());
@@ -3096,7 +3096,7 @@ public class VersionGarbageCollectorIT {
//Following would not work for Mongo as the delete happened on the server side
//And entries from cache are not evicted
- //assertTrue(ImmutableList.copyOf(getDoc("/test2/foo").getAllPreviousDocs()).isEmpty());
+ //assertTrue(CollectionUtils.toImmutableList(getDoc("/test2/foo").getAllPreviousDocs()).isEmpty());
}
/**
@@ -3813,7 +3813,7 @@ public class VersionGarbageCollectorIT {
NodeDocument doc = getDoc("/foo");
assertNotNull(doc);
- List<NodeDocument> prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs());
+ List<NodeDocument> prevDocs = CollectionUtils.toImmutableList(doc.getAllPreviousDocs());
assertEquals(1, prevDocs.size());
assertEquals(SplitDocType.DEFAULT_NO_BRANCH, prevDocs.get(0).getSplitDocType());
@@ -3824,7 +3824,7 @@ public class VersionGarbageCollectorIT {
doc = getDoc("/foo");
assertNotNull(doc);
- prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs());
+ prevDocs = CollectionUtils.toImmutableList(doc.getAllPreviousDocs());
assertEquals(0, prevDocs.size());
assertEquals(value, store1.getRoot().getChildNode("foo").getString("prop"));
@@ -3851,7 +3851,7 @@ public class VersionGarbageCollectorIT {
// now /foo must have previous docs
NodeDocument doc = getDoc("/foo");
- List<NodeDocument> prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs());
+ List<NodeDocument> prevDocs = CollectionUtils.toImmutableList(doc.getAllPreviousDocs());
assertEquals(1, prevDocs.size());
assertEquals(SplitDocType.DEFAULT_NO_BRANCH, prevDocs.get(0).getSplitDocType());
@@ -3877,7 +3877,7 @@ public class VersionGarbageCollectorIT {
doc = getDoc("/foo");
assertNotNull(doc);
- prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs());
+ prevDocs = CollectionUtils.toImmutableList(doc.getAllPreviousDocs());
assertEquals(0, prevDocs.size());
// check value
assertEquals(value, store1.getRoot().getChildNode("foo").getString("prop"));
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java
index 9e0f958c53..7d3a76f4b6 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java
@@ -33,6 +33,7 @@ import org.apache.jackrabbit.oak.api.CommitFailedException;
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.CollectionUtils;
import org.apache.jackrabbit.oak.plugins.document.Collection;
import org.apache.jackrabbit.oak.plugins.document.Document;
import org.apache.jackrabbit.oak.plugins.document.DocumentMKBuilderProvider;
@@ -67,7 +68,6 @@ import org.junit.Test;
import static java.lang.String.format;
import static java.util.Objects.requireNonNull;
-import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf;
import static org.apache.commons.io.FileUtils.ONE_MB;
import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
import static org.apache.jackrabbit.oak.commons.PathUtils.concat;
@@ -1047,7 +1047,7 @@ public class DocumentBundlingTest {
}
private static List<String> childNames(NodeState state, String path){
- return copyOf(getNode(state, path).getChildNodeNames());
+ return CollectionUtils.toImmutableList(getNode(state, path).getChildNodeNames());
}
static NodeBuilder newNode(String typeName){
diff --git a/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/json/JsonSerializer.java b/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/json/JsonSerializer.java
index cff18a5433..10571bf982 100644
--- a/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/json/JsonSerializer.java
+++ b/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/json/JsonSerializer.java
@@ -30,10 +30,10 @@ import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.jetbrains.annotations.NotNull;
import javax.jcr.PropertyType;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.oak.commons.json.JsopBuilder;
import org.apache.jackrabbit.oak.api.Blob;
import org.apache.jackrabbit.oak.api.PropertyState;
@@ -188,7 +188,7 @@ public class JsonSerializer {
private Iterable<? extends ChildNodeEntry> getChildNodeEntries(NodeState node, String basePath) {
PropertyState order = node.getProperty(":childOrder");
if (order != null) {
- List<String> names = ImmutableList.copyOf(order.getValue(NAMES));
+ List<String> names = CollectionUtils.toImmutableList(order.getValue(NAMES));
List<ChildNodeEntry> entries = new ArrayList<>(names.size());
for (String name : names) {
try {
diff --git a/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java b/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
index 2457bc7df8..35fbdbcdcc 100644
--- a/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
+++ b/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
@@ -58,7 +58,6 @@ import javax.jcr.nodetype.PropertyDefinitionTemplate;
import javax.jcr.security.Privilege;
import org.apache.jackrabbit.guava.common.base.Stopwatch;
-import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.Lists;
import org.apache.commons.collections4.bidimap.DualHashBidiMap;
@@ -79,6 +78,7 @@ import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.api.Root;
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.conditions.Validate;
import org.apache.jackrabbit.oak.namepath.NamePathMapper;
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
@@ -774,7 +774,7 @@ public class RepositoryUpgrade {
while (it.hasNext()) {
Privilege aggrPriv = it.next();
- List<String> aggrNames = Lists.transform(ImmutableList.copyOf(aggrPriv.getDeclaredAggregatePrivileges()),
+ List<String> aggrNames = Lists.transform(CollectionUtils.toImmutableList(aggrPriv.getDeclaredAggregatePrivileges()),
input -> (input == null) ? null : input.getName());
if (allAggregatesRegistered(pMgr, aggrNames)) {
pMgr.registerPrivilege(aggrPriv.getName(), aggrPriv.isAbstract(), aggrNames.toArray(new String[aggrNames.size()]));
diff --git a/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/PrivilegeUpgradeTest.java b/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/PrivilegeUpgradeTest.java
index cc7fd53684..3482c4874f 100644
--- a/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/PrivilegeUpgradeTest.java
+++ b/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/PrivilegeUpgradeTest.java
@@ -187,7 +187,7 @@ public class PrivilegeUpgradeTest extends AbstractRepositoryUpgradeTest {
assertNotNull(aggregate);
assertFalse(aggregate.isAbstract());
assertTrue(aggregate.isAggregate());
- List<Privilege> agg = ImmutableList.copyOf(aggregate.getDeclaredAggregatePrivileges());
+ List<Privilege> agg = CollectionUtils.toImmutableList(aggregate.getDeclaredAggregatePrivileges());
assertEquals(2, agg.size());
assertTrue(agg.contains(privilege));
assertTrue(agg.contains(manager.getPrivilege(JCR_READ)));
@@ -196,7 +196,7 @@ public class PrivilegeUpgradeTest extends AbstractRepositoryUpgradeTest {
assertNotNull(aggregate2);
assertTrue(aggregate2.isAbstract());
assertTrue(aggregate2.isAggregate());
- List<Privilege> agg2 = ImmutableList.copyOf(aggregate2.getDeclaredAggregatePrivileges());
+ List<Privilege> agg2 = CollectionUtils.toImmutableList(aggregate2.getDeclaredAggregatePrivileges());
assertEquals(2, agg2.size());
assertTrue(agg2.contains(aggregate));
assertTrue(agg2.contains(privilege2));