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 2025/01/23 14:41:42 UTC
(jackrabbit-oak) 01/01: OAK-11427 : removed usage of Guava Iterables.isEmpty
This is an automated email from the ASF dual-hosted git repository.
daim pushed a commit to branch OAK-11427
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit b55e398bb98ff06109f1c9922f058e71112ac7f7
Author: Rishabh Kumar <di...@adobe.com>
AuthorDate: Thu Jan 23 20:11:30 2025 +0530
OAK-11427 : removed usage of Guava Iterables.isEmpty
---
.../principal/SyncHandlerMappingTrackerTest.java | 17 +++---
.../ldap/impl/LdapIdentityProviderTest.java | 3 +-
.../authorization/cug/impl/NestedCugHook.java | 3 +-
.../impl/PrincipalPolicyValidatorProvider.java | 3 +-
.../impl/PrincipalPolicyImporterTest.java | 3 +-
.../oak/commons/collections/IterableUtils.java | 48 ++++++++++++++++
.../oak/commons/collections/IterableUtilsTest.java | 65 ++++++++++++++++++++++
.../oak/plugins/nodetype/TypeRegistration.java | 4 +-
.../accesscontrol/AccessControlValidator.java | 3 +-
.../index/property/AsyncPropertyIndexTest.java | 9 +--
.../oak/plugins/tree/impl/TreeUtilTest.java | 17 +++---
.../oak/jcr/observation/EventFactory.java | 4 +-
.../hybrid/LuceneJournalPropertyBuilderTest.java | 5 +-
.../oak/plugins/index/search/IndexDefinition.java | 3 +-
.../security/privilege/PrivilegeBitsProvider.java | 5 +-
.../jackrabbit/oak/plugins/tree/TreeUtilTest.java | 3 +-
.../spi/security/CompositeConfigurationTest.java | 5 +-
.../privilege/PrivilegeBitsProviderTest.java | 7 ++-
18 files changed, 167 insertions(+), 40 deletions(-)
diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/SyncHandlerMappingTrackerTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/SyncHandlerMappingTrackerTest.java
index 48fd167001..d5eac6dd83 100644
--- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/SyncHandlerMappingTrackerTest.java
+++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/SyncHandlerMappingTrackerTest.java
@@ -17,6 +17,7 @@
package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal;
import org.apache.jackrabbit.guava.common.collect.Iterables;
+import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
import org.apache.jackrabbit.oak.commons.collections.SetUtils;
import org.apache.jackrabbit.oak.spi.security.authentication.external.impl.SyncHandlerMapping;
import org.junit.Before;
@@ -49,21 +50,21 @@ public class SyncHandlerMappingTrackerTest {
@Test
public void testAddingServiceWithoutProperties() {
tracker.addingService(ref);
- assertTrue(Iterables.isEmpty(tracker.getIdpNames("testSH")));
+ assertTrue(IterableUtils.isEmpty(tracker.getIdpNames("testSH")));
}
@Test
public void testAddingServiceWithIdpProp() {
when(ref.getProperty(PARAM_IDP_NAME)).thenReturn("testIDP");
tracker.addingService(ref);
- assertTrue(Iterables.isEmpty(tracker.getIdpNames("testSH")));
+ assertTrue(IterableUtils.isEmpty(tracker.getIdpNames("testSH")));
}
@Test
public void testAddingServiceWithSyncHandlerProp() {
when(ref.getProperty(PARAM_SYNC_HANDLER_NAME)).thenReturn("testSH");
tracker.addingService(ref);
- assertTrue(Iterables.isEmpty(tracker.getIdpNames("testSH")));
+ assertTrue(IterableUtils.isEmpty(tracker.getIdpNames("testSH")));
}
@Test
@@ -94,21 +95,21 @@ public class SyncHandlerMappingTrackerTest {
@Test
public void testModifiedServiceWithoutProperties() {
tracker.modifiedService(ref, service);
- assertTrue(Iterables.isEmpty(tracker.getIdpNames("testSH")));
+ assertTrue(IterableUtils.isEmpty(tracker.getIdpNames("testSH")));
}
@Test
public void testModifiedServiceWithIdpProp() {
when(ref.getProperty(PARAM_IDP_NAME)).thenReturn("testIDP");
tracker.modifiedService(ref, service);
- assertTrue(Iterables.isEmpty(tracker.getIdpNames("testSH")));
+ assertTrue(IterableUtils.isEmpty(tracker.getIdpNames("testSH")));
}
@Test
public void testModifiedServiceWithSyncHandlerProp() {
when(ref.getProperty(PARAM_SYNC_HANDLER_NAME)).thenReturn("testSH");
tracker.modifiedService(ref, service);
- assertTrue(Iterables.isEmpty(tracker.getIdpNames("testSH")));
+ assertTrue(IterableUtils.isEmpty(tracker.getIdpNames("testSH")));
}
@Test
@@ -126,7 +127,7 @@ public class SyncHandlerMappingTrackerTest {
when(ref.getProperty(PARAM_SYNC_HANDLER_NAME)).thenReturn("testSH-3");
when(ref.getProperty(PARAM_IDP_NAME)).thenReturn("testIDP-3");
tracker.modifiedService(ref, service);
- assertTrue(Iterables.isEmpty(tracker.getIdpNames("testSH")));
+ assertTrue(IterableUtils.isEmpty(tracker.getIdpNames("testSH")));
assertEquals(Set.of("testIDP-3"), SetUtils.toSet(tracker.getIdpNames("testSH-3")));
}
@@ -138,6 +139,6 @@ public class SyncHandlerMappingTrackerTest {
tracker.addingService(ref);
tracker.removedService(ref, service);
- assertTrue(Iterables.isEmpty(tracker.getIdpNames("testSH")));
+ assertTrue(IterableUtils.isEmpty(tracker.getIdpNames("testSH")));
}
}
\ No newline at end of file
diff --git a/oak-auth-ldap/src/test/java/org/apache/jackrabbit/oak/security/authentication/ldap/impl/LdapIdentityProviderTest.java b/oak-auth-ldap/src/test/java/org/apache/jackrabbit/oak/security/authentication/ldap/impl/LdapIdentityProviderTest.java
index 6b562f0a7d..9887a75044 100644
--- a/oak-auth-ldap/src/test/java/org/apache/jackrabbit/oak/security/authentication/ldap/impl/LdapIdentityProviderTest.java
+++ b/oak-auth-ldap/src/test/java/org/apache/jackrabbit/oak/security/authentication/ldap/impl/LdapIdentityProviderTest.java
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.security.authentication.ldap.impl;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.guava.common.collect.Iterators;
+import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
import org.apache.jackrabbit.oak.commons.collections.SetUtils;
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup;
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity;
@@ -211,7 +212,7 @@ public class LdapIdentityProviderTest extends AbstractLdapIdentityProviderTest {
ExternalGroup gr = idp.getGroup(TEST_GROUP1_NAME);
Iterable<ExternalIdentityRef> memberrefs = gr.getDeclaredMembers();
- assertTrue(Iterables.isEmpty(memberrefs));
+ assertTrue(IterableUtils.isEmpty(memberrefs));
}
@Test
diff --git a/oak-authorization-cug/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NestedCugHook.java b/oak-authorization-cug/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NestedCugHook.java
index 87464a8b6a..d390118110 100644
--- a/oak-authorization-cug/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NestedCugHook.java
+++ b/oak-authorization-cug/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NestedCugHook.java
@@ -24,6 +24,7 @@ import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
import org.apache.jackrabbit.oak.plugins.memory.PropertyBuilder;
import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
import org.apache.jackrabbit.oak.spi.commit.PostValidationHook;
@@ -294,7 +295,7 @@ class NestedCugHook implements PostValidationHook, CugConstants {
// are still present.
Set<String> reconnect = getCugPathsToReconnect(before);
if (isRoot) {
- if (!Iterables.isEmpty(reconnect)) {
+ if (!IterableUtils.isEmpty(reconnect)) {
afterBuilder.setProperty(HIDDEN_NESTED_CUGS, reconnect, Type.STRINGS);
afterBuilder.setProperty(HIDDEN_TOP_CUG_CNT, reconnect.size());
}
diff --git a/oak-authorization-principalbased/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyValidatorProvider.java b/oak-authorization-principalbased/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyValidatorProvider.java
index 8ab663830b..8dfa07f90a 100644
--- a/oak-authorization-principalbased/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyValidatorProvider.java
+++ b/oak-authorization-principalbased/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyValidatorProvider.java
@@ -26,6 +26,7 @@ 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.StringUtils;
+import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
import org.apache.jackrabbit.oak.commons.conditions.Validate;
import org.apache.jackrabbit.oak.namepath.NamePathMapper;
import org.apache.jackrabbit.oak.plugins.nodetype.TypePredicate;
@@ -221,7 +222,7 @@ class PrincipalPolicyValidatorProvider extends ValidatorProvider implements Cons
throw accessControlViolation(36, "Isolated entry of principal policy at " + entryPath);
}
Iterable<String> privilegeNames = nodeState.getNames(REP_PRIVILEGES);
- if (Iterables.isEmpty(privilegeNames)) {
+ if (IterableUtils.isEmpty(privilegeNames)) {
throw accessControlViolation(37, "Empty rep:privileges property at " + entryPath);
}
PrivilegeManager privilegeManager = mgrProvider.getPrivilegeManager();
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 99f9492c77..d63ec6f807 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
@@ -20,6 +20,7 @@ import org.apache.jackrabbit.guava.common.collect.Iterables;
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.IterableUtils;
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;
@@ -474,7 +475,7 @@ public class PrincipalPolicyImporterTest extends AbstractPrincipalBasedTest {
policyTree = root.getTree(policyTree.getPath());
assertTrue(policyTree.exists());
assertTrue(policyTree.hasProperty(REP_PRINCIPAL_NAME));
- assertTrue(Iterables.isEmpty(policyTree.getChildren()));
+ assertTrue(IterableUtils.isEmpty(policyTree.getChildren()));
}
@Test(expected = IllegalStateException.class)
diff --git a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/IterableUtils.java b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/IterableUtils.java
new file mode 100644
index 0000000000..ad88546c76
--- /dev/null
+++ b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/IterableUtils.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.commons.collections;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Collection;
+
+/**
+ * Utility methods for {@link Iterable} conversions.
+ */
+public class IterableUtils {
+
+ private IterableUtils() {
+ // no instances for you
+ }
+
+ /**
+ * Checks if an iterable is empty.
+ *
+ * @param iterable the iterable to check, must not be {@code null}
+ * @param <T> the type of elements in the iterable
+ * @return {@code true} if the iterable is empty, {@code false} otherwise
+ * @throws NullPointerException if the iterable is {@code null}
+ */
+ public static <T> boolean isEmpty(@NotNull Iterable<T> iterable) {
+ if (iterable instanceof Collection) {
+ return ((Collection<?>) iterable).isEmpty();
+ }
+ return StreamUtils.toStream(iterable).findAny().isEmpty();
+ }
+}
diff --git a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/IterableUtilsTest.java b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/IterableUtilsTest.java
new file mode 100644
index 0000000000..630f90a314
--- /dev/null
+++ b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/IterableUtilsTest.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.commons.collections;
+
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Unit tests for the {@link IterableUtils} class.
+ * <p>
+ * This class contains test cases to verify the functionality of the methods
+ * in the {@link IterableUtils} class.
+ */
+public class IterableUtilsTest {
+
+ @Test
+ public void testIsEmptyWithEmptyList() {
+ List<String> emptyList = Collections.emptyList();
+ Assert.assertTrue(IterableUtils.isEmpty(emptyList));
+ }
+
+ @Test
+ public void testIsEmptyWithNonEmptyList() {
+ List<String> nonEmptyList = List.of("one", "two", "three");
+ Assert.assertFalse(IterableUtils.isEmpty(nonEmptyList));
+ }
+
+ @Test
+ public void testIsEmptyWithEmptyIterable() {
+ Iterable<String> emptyIterable = Collections::emptyIterator;
+ Assert.assertTrue(IterableUtils.isEmpty(emptyIterable));
+ }
+
+ @Test
+ public void testIsEmptyWithNonEmptyIterable() {
+ Iterable<String> nonEmptyIterable = List.of("one", "two", "three");
+ Assert.assertFalse(IterableUtils.isEmpty(nonEmptyIterable));
+ }
+
+ @Test
+ public void testIsEmptyWithNullIterable() {
+ Assert.assertThrows(NullPointerException.class, () -> IterableUtils.isEmpty(null));
+ }
+
+}
\ No newline at end of file
diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeRegistration.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeRegistration.java
index 1ad0ff3cc9..133bc24299 100644
--- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeRegistration.java
+++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeRegistration.java
@@ -18,7 +18,6 @@ package org.apache.jackrabbit.oak.plugins.nodetype;
import static org.apache.jackrabbit.guava.common.collect.Iterables.addAll;
import static org.apache.jackrabbit.guava.common.collect.Iterables.contains;
-import static org.apache.jackrabbit.guava.common.collect.Iterables.isEmpty;
import static java.util.Collections.emptyList;
import static org.apache.jackrabbit.JcrConstants.JCR_CHILDNODEDEFINITION;
import static org.apache.jackrabbit.JcrConstants.JCR_ISMIXIN;
@@ -68,6 +67,7 @@ import java.util.Set;
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
import org.apache.jackrabbit.oak.commons.collections.ListUtils;
import org.apache.jackrabbit.oak.commons.collections.SetUtils;
import org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants;
@@ -253,7 +253,7 @@ class TypeRegistration extends DefaultNodeStateDiff {
// This is a primary node type.
// Make sure jcr:supertypes contains nt:base when needed.
Iterable<String> supertypes = getNames(type, JCR_SUPERTYPES);
- if (isEmpty(supertypes)) {
+ if (IterableUtils.isEmpty(supertypes)) {
addNameToList(type, JCR_SUPERTYPES, NT_BASE);
} else {
// is any of the supertypes a primary node type?
diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlValidator.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlValidator.java
index ff1ad6f726..5aad767b52 100644
--- a/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlValidator.java
+++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlValidator.java
@@ -32,6 +32,7 @@ import org.apache.jackrabbit.api.security.authorization.PrivilegeManager;
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.commons.collections.IterableUtils;
import org.apache.jackrabbit.oak.plugins.nodetype.TypePredicate;
import org.apache.jackrabbit.oak.plugins.tree.TreeConstants;
import org.apache.jackrabbit.oak.plugins.tree.TreeProvider;
@@ -270,7 +271,7 @@ class AccessControlValidator extends DefaultValidator implements AccessControlCo
@NotNull
private static Iterable<String> getPrivilegeNames(@NotNull Tree aceNode) throws CommitFailedException {
Iterable<String> privilegeNames = TreeUtil.getNames(aceNode, REP_PRIVILEGES);
- if (Iterables.isEmpty(privilegeNames)) {
+ if (IterableUtils.isEmpty(privilegeNames)) {
throw accessViolation(9, "Missing privileges at " + aceNode.getPath());
}
return privilegeNames;
diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/AsyncPropertyIndexTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/AsyncPropertyIndexTest.java
index a300e8c189..32c67cf583 100644
--- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/AsyncPropertyIndexTest.java
+++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/AsyncPropertyIndexTest.java
@@ -31,6 +31,7 @@ import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.Set;
+import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
import org.apache.jackrabbit.oak.commons.collections.SetUtils;
import org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate;
import org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider;
@@ -64,7 +65,7 @@ public class AsyncPropertyIndexTest {
@Test
public void testAsyncPropertyLookup() throws Exception {
NodeStore store = new MemoryNodeStore();
- assertTrue(Iterables.isEmpty(store.checkpoints()));
+ assertTrue(IterableUtils.isEmpty(store.checkpoints()));
NodeBuilder builder = store.getRoot().builder();
@@ -103,7 +104,7 @@ public class AsyncPropertyIndexTest {
async.close();
assertEquals(null, store.getRoot().getChildNode(INDEX_DEFINITIONS_NAME)
.getChildNode("foo").getString(ASYNC_PROPERTY_NAME));
- assertTrue(Iterables.isEmpty(store.checkpoints()));
+ assertTrue(IterableUtils.isEmpty(store.checkpoints()));
// add content, it should be indexed synchronously
builder = store.getRoot().builder();
@@ -131,12 +132,12 @@ public class AsyncPropertyIndexTest {
@Test
public void testAsyncPropertyNoChanges() throws Exception {
NodeStore store = new MemoryNodeStore();
- assertTrue(Iterables.isEmpty(store.checkpoints()));
+ assertTrue(IterableUtils.isEmpty(store.checkpoints()));
AsyncIndexUpdate async = new AsyncIndexUpdate(ASYNC_REINDEX_VALUE,
store, provider, true);
async.run();
async.run();
async.close();
- assertTrue(Iterables.isEmpty(store.checkpoints()));
+ assertTrue(IterableUtils.isEmpty(store.checkpoints()));
}
}
diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/tree/impl/TreeUtilTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/tree/impl/TreeUtilTest.java
index ec8446fc8a..cb600d9838 100644
--- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/tree/impl/TreeUtilTest.java
+++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/tree/impl/TreeUtilTest.java
@@ -25,6 +25,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.LazyValue;
+import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
import org.apache.jackrabbit.oak.plugins.tree.TreeUtil;
import org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants;
import org.junit.Test;
@@ -122,8 +123,8 @@ public class TreeUtilTest extends AbstractSecurityTest {
@Test
public void testGetMixinTypeNamesMissingAccessible() {
- assertTrue(Iterables.isEmpty(TreeUtil.getMixinTypeNames(root.getTree("/"))));
- assertTrue(Iterables.isEmpty(TreeUtil.getMixinTypeNames(root.getTree("/"), new LazyValue<Tree>() {
+ assertTrue(IterableUtils.isEmpty(TreeUtil.getMixinTypeNames(root.getTree("/"))));
+ assertTrue(IterableUtils.isEmpty(TreeUtil.getMixinTypeNames(root.getTree("/"), new LazyValue<Tree>() {
@Override
protected Tree createValue() {
return root.getTree("/");
@@ -134,12 +135,12 @@ public class TreeUtilTest extends AbstractSecurityTest {
@Test
public void testGetMixinTypeNamesMissingNotAccessible() throws Exception {
Tree tree = root.getTree("/");
- assertTrue(Iterables.isEmpty(TreeUtil.getMixinTypeNames(tree)));
+ assertTrue(IterableUtils.isEmpty(TreeUtil.getMixinTypeNames(tree)));
try (ContentSession cs = login(new GuestCredentials())) {
Root guestRoot = cs.getLatestRoot();
- assertTrue(Iterables.isEmpty(TreeUtil.getMixinTypeNames(guestRoot.getTree("/"))));
- assertTrue(Iterables.isEmpty(TreeUtil.getMixinTypeNames(guestRoot.getTree("/"), new LazyValue<Tree>() {
+ assertTrue(IterableUtils.isEmpty(TreeUtil.getMixinTypeNames(guestRoot.getTree("/"))));
+ assertTrue(IterableUtils.isEmpty(TreeUtil.getMixinTypeNames(guestRoot.getTree("/"), new LazyValue<Tree>() {
@Override
protected Tree createValue() {
return tree;
@@ -177,8 +178,8 @@ public class TreeUtilTest extends AbstractSecurityTest {
try (ContentSession cs = login(new GuestCredentials())) {
Root guestRoot = cs.getLatestRoot();
- assertTrue(Iterables.isEmpty(TreeUtil.getMixinTypeNames(guestRoot.getTree(path))));
- assertTrue(Iterables.elementsEqual(expected, TreeUtil.getMixinTypeNames(guestRoot.getTree(path), new LazyValue<Tree>() {
+ assertTrue(IterableUtils.isEmpty(TreeUtil.getMixinTypeNames(guestRoot.getTree(path))));
+ assertTrue(IterableUtils.elementsEqual(expected, TreeUtil.getMixinTypeNames(guestRoot.getTree(path), new LazyValue<Tree>() {
@Override
protected Tree createValue() {
return testTree;
@@ -197,7 +198,7 @@ public class TreeUtilTest extends AbstractSecurityTest {
when(t.hasProperty(JcrConstants.JCR_MIXINTYPES)).thenReturn(false);
when(t.getStatus()).thenReturn(Tree.Status.NEW);
- assertTrue(Iterables.isEmpty(TreeUtil.getMixinTypeNames(t, new LazyValue<Tree>() {
+ assertTrue(IterableUtils.isEmpty(TreeUtil.getMixinTypeNames(t, new LazyValue<Tree>() {
@Override
protected Tree createValue() {
return testTree;
diff --git a/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/EventFactory.java b/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/EventFactory.java
index d4b7e22ec8..f8409633f7 100644
--- a/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/EventFactory.java
+++ b/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/EventFactory.java
@@ -18,7 +18,6 @@
*/
package org.apache.jackrabbit.oak.jcr.observation;
-import static org.apache.jackrabbit.guava.common.collect.Iterables.isEmpty;
import static org.apache.jackrabbit.guava.common.collect.Iterables.toArray;
import static java.util.Collections.emptyMap;
import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES;
@@ -39,6 +38,7 @@ import org.apache.jackrabbit.api.observation.JackrabbitEvent;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.blob.BlobAccessProvider;
import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
import org.apache.jackrabbit.oak.namepath.NamePathMapper;
import org.apache.jackrabbit.oak.plugins.value.jcr.PartialValueFactory;
import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
@@ -221,7 +221,7 @@ public class EventFactory {
}
private Map<String, ?> createInfoMap(String primaryType, Iterable<String> mixinTypes) {
- if (isEmpty(mixinTypes)) {
+ if (IterableUtils.isEmpty(mixinTypes)) {
return Map.of(
JCR_PRIMARYTYPE, mapper.getJcrName(primaryType));
} else {
diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/LuceneJournalPropertyBuilderTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/LuceneJournalPropertyBuilderTest.java
index 0e77906a37..c58ec52925 100644
--- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/LuceneJournalPropertyBuilderTest.java
+++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/LuceneJournalPropertyBuilderTest.java
@@ -22,6 +22,7 @@ package org.apache.jackrabbit.oak.plugins.index.lucene.hybrid;
import org.apache.jackrabbit.guava.common.collect.HashMultimap;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.guava.common.collect.Multimap;
+import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
import org.junit.Test;
import static org.hamcrest.Matchers.containsInAnyOrder;
@@ -40,7 +41,7 @@ public class LuceneJournalPropertyBuilderTest {
public void nullProperty() throws Exception{
builder.addProperty(null);
assertEquals("{}", builder.buildAsString());
- assertTrue(Iterables.isEmpty(((IndexedPaths)builder.build())));
+ assertTrue(IterableUtils.isEmpty(((IndexedPaths)builder.build())));
}
@Test
@@ -51,7 +52,7 @@ public class LuceneJournalPropertyBuilderTest {
builder2.addSerializedProperty(null);
builder2.addSerializedProperty(builder.buildAsString());
- assertTrue(Iterables.isEmpty(((IndexedPaths)builder2.build())));
+ assertTrue(IterableUtils.isEmpty(((IndexedPaths)builder2.build())));
}
@Test
public void addJsonLessThanMaxBuilderSize() throws Exception {
diff --git a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/IndexDefinition.java b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/IndexDefinition.java
index c473fbf630..f3797528cc 100644
--- a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/IndexDefinition.java
+++ b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/IndexDefinition.java
@@ -26,6 +26,7 @@ import org.apache.jackrabbit.oak.api.Root;
import org.apache.jackrabbit.oak.api.Tree;
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
import org.apache.jackrabbit.oak.commons.collections.SetUtils;
import org.apache.jackrabbit.oak.namepath.NamePathMapper;
import org.apache.jackrabbit.oak.plugins.index.IndexConstants;
@@ -1617,7 +1618,7 @@ public class IndexDefinition implements Aggregate.AggregateMapper {
//Also include all immediate leaf propNode names
for (ChildNodeEntry cne : propNodeState.getChildNodeEntries()) {
if (!propNamesSet.contains(cne.getName())
- && Iterables.isEmpty(cne.getNodeState().getChildNodeNames())) {
+ && IterableUtils.isEmpty(cne.getNodeState().getChildNodeNames())) {
propNamesSet.add(cne.getName());
}
}
diff --git a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsProvider.java b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsProvider.java
index 346b9d314c..02c92e13f7 100644
--- a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsProvider.java
+++ b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsProvider.java
@@ -33,6 +33,7 @@ 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.collections.IterableUtils;
import org.apache.jackrabbit.oak.namepath.NameMapper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -91,7 +92,7 @@ public final class PrivilegeBitsProvider implements PrivilegeConstants {
*/
@NotNull
public PrivilegeBits getBits(@NotNull Iterable<String> privilegeNames) {
- if (Iterables.isEmpty(privilegeNames)) {
+ if (IterableUtils.isEmpty(privilegeNames)) {
return PrivilegeBits.EMPTY;
}
@@ -116,7 +117,7 @@ public final class PrivilegeBitsProvider implements PrivilegeConstants {
if (!validateNames) {
return getBits(privilegeNames);
}
- if (Iterables.isEmpty(privilegeNames)) {
+ if (IterableUtils.isEmpty(privilegeNames)) {
return PrivilegeBits.EMPTY;
}
PrivilegeBits bits = PrivilegeBits.getInstance();
diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/plugins/tree/TreeUtilTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/plugins/tree/TreeUtilTest.java
index d84e973f25..ebea77b677 100644
--- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/plugins/tree/TreeUtilTest.java
+++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/plugins/tree/TreeUtilTest.java
@@ -24,6 +24,7 @@ import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.commons.LazyValue;
import org.apache.jackrabbit.oak.commons.PathUtils;
import org.apache.jackrabbit.oak.commons.UUIDUtils;
+import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
import org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants;
import org.junit.Test;
@@ -157,7 +158,7 @@ public class TreeUtilTest extends AbstractTreeTest {
@Test
public void testGetMixinTypeNamesNewTreeLazy() {
Tree newTree = when(rootTree.getChild("x").getStatus()).thenReturn(Tree.Status.NEW).getMock();
- assertTrue(Iterables.isEmpty(TreeUtil.getMixinTypeNames(newTree, new LazyValue<Tree>() {
+ assertTrue(IterableUtils.isEmpty(TreeUtil.getMixinTypeNames(newTree, new LazyValue<Tree>() {
@Override
protected Tree createValue() {
throw new RuntimeException("should not get here");
diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/CompositeConfigurationTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/CompositeConfigurationTest.java
index 78e8037880..763f6930b1 100644
--- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/CompositeConfigurationTest.java
+++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/CompositeConfigurationTest.java
@@ -17,6 +17,7 @@
package org.apache.jackrabbit.oak.spi.security;
import org.apache.jackrabbit.guava.common.collect.Iterables;
+import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
import org.apache.jackrabbit.oak.plugins.tree.RootProvider;
import org.apache.jackrabbit.oak.plugins.tree.TreeProvider;
import org.apache.jackrabbit.oak.spi.commit.CommitHook;
@@ -391,10 +392,10 @@ public class CompositeConfigurationTest extends AbstractCompositeConfigurationTe
@Test
public void testGetMonitors() {
StatisticsProvider statisticsProvider = StatisticsProvider.NOOP;
- assertTrue(Iterables.isEmpty(compositeConfiguration.getMonitors(statisticsProvider)));
+ assertTrue(IterableUtils.isEmpty(compositeConfiguration.getMonitors(statisticsProvider)));
addConfiguration(new SecurityConfiguration.Default());
- assertTrue(Iterables.isEmpty(compositeConfiguration.getMonitors(statisticsProvider)));
+ assertTrue(IterableUtils.isEmpty(compositeConfiguration.getMonitors(statisticsProvider)));
Monitor<LoginModuleMonitor> monitor = mock(LoginModuleMonitor.class);
SecurityConfiguration withMonitors = new SecurityConfiguration.Default() {
diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsProviderTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsProviderTest.java
index 2f434ce777..182e02a02b 100644
--- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsProviderTest.java
+++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsProviderTest.java
@@ -21,6 +21,7 @@ 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.collections.IterableUtils;
import org.apache.jackrabbit.oak.commons.collections.SetUtils;
import org.apache.jackrabbit.oak.namepath.NamePathMapper;
import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
@@ -368,12 +369,12 @@ public class PrivilegeBitsProviderTest implements PrivilegeConstants {
@Test
public void testGetAggregatedPrivilegeNamesEmpty() {
- assertTrue(Iterables.isEmpty(bitsProvider.getAggregatedPrivilegeNames()));
+ assertTrue(IterableUtils.isEmpty(bitsProvider.getAggregatedPrivilegeNames()));
}
@Test
public void testGetAggregatedPrivilegeNamesEmptyArray() {
- assertTrue(Iterables.isEmpty(bitsProvider.getAggregatedPrivilegeNames()));
+ assertTrue(IterableUtils.isEmpty(bitsProvider.getAggregatedPrivilegeNames()));
}
@Test
@@ -454,7 +455,7 @@ public class PrivilegeBitsProviderTest implements PrivilegeConstants {
when(privTree.getChild(KNOWN_PRIV_NAME)).thenReturn(pTree);
Iterable<String> result = bitsProvider.getAggregatedPrivilegeNames(KNOWN_PRIV_NAME);
- assertTrue(Iterables.isEmpty(result));
+ assertTrue(IterableUtils.isEmpty(result));
}
@Test