Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAK-11449 : removed usage of Guava Iterables.concat #2048

Merged
merged 1 commit into from
Feb 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.jackrabbit.oak.spi.security.authentication.external.impl;

import org.apache.commons.collections4.IterableUtils;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.api.security.user.Authorizable;
import org.apache.jackrabbit.api.security.user.UserManager;
Expand Down Expand Up @@ -88,7 +89,7 @@ private void createAutoMembershipGroups() throws RepositoryException {
DefaultSyncConfig sc = createSyncConfig();
UserManager um = getUserManager(r);
// create automembership groups
for (String id : Iterables.concat(sc.user().getAutoMembership(), sc.group().getAutoMembership())) {
for (String id : IterableUtils.chainedIterable(sc.user().getAutoMembership(), sc.group().getAutoMembership())) {
um.createGroup(id);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal;

import org.apache.commons.collections4.IterableUtils;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.api.security.principal.GroupPrincipal;
import org.apache.jackrabbit.api.security.user.Group;
Expand Down Expand Up @@ -81,7 +82,7 @@ protected DefaultSyncConfig createSyncConfig() {
}

@NotNull String[] getAutoMembership() {
return Iterables.toArray(Iterables.concat(syncConfig.user().getAutoMembership(),syncConfig.group().getAutoMembership()), String.class);
return Iterables.toArray(IterableUtils.chainedIterable(syncConfig.user().getAutoMembership(),syncConfig.group().getAutoMembership()), String.class);
}

@NotNull AutoMembershipConfig getAutoMembershipConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import javax.jcr.GuestCredentials;
import javax.jcr.Session;

import org.apache.commons.collections4.IterableUtils;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.oak.api.ContentSession;
import org.apache.jackrabbit.oak.api.Root;
Expand Down Expand Up @@ -519,7 +520,7 @@ public void testHasReadPrivilegesAtCug() {
*/
@Test
public void testHasNonReadPrivileges() {
for (String p : Iterables.concat(READABLE_PATHS, NOT_READABLE_PATHS)) {
for (String p : IterableUtils.chainedIterable(READABLE_PATHS, NOT_READABLE_PATHS)) {
Tree tree = root.getTree(p);
if (tree.exists()) {
assertFalse(cugPermProvider.hasPrivileges(tree, PrivilegeConstants.JCR_WRITE));
Expand Down Expand Up @@ -646,7 +647,7 @@ public void testGetTreePermissionNonExistingVersionTree() {
*/
@Test
public void testIsGrantedNonRead() {
for (String p : Iterables.concat(READABLE_PATHS, NOT_READABLE_PATHS)) {
for (String p : IterableUtils.chainedIterable(READABLE_PATHS, NOT_READABLE_PATHS)) {
Tree tree = root.getTree(p);
if (tree.exists()) {
assertFalse(cugPermProvider.isGranted(tree, null, Permissions.ALL));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.jackrabbit.oak.spi.security.authorization.cug.impl;

import org.apache.commons.collections4.IterableUtils;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.oak.api.Tree;
import org.apache.jackrabbit.oak.api.Type;
Expand Down Expand Up @@ -354,7 +355,7 @@ public void testHiddenChildNodeAdded() throws Exception {

NodeState child = mock(NodeState.class);
Iterable newCnes = Collections.singleton(new MemoryChildNodeEntry(":hidden", child));
Iterable cnes = Iterables.concat(newCnes, before.getChildNodeEntries());
Iterable cnes = IterableUtils.chainedIterable(newCnes, before.getChildNodeEntries());
when(after.getChildNodeEntries()).thenReturn(cnes);
when(after.getChildNode(":hidden")).thenReturn(child);

Expand All @@ -373,13 +374,13 @@ public void testHiddenChildNodeChanged() {

NodeState child = mock(NodeState.class);
Iterable hidden = Collections.singleton(new MemoryChildNodeEntry(":hidden", child));
Iterable cnes = Iterables.concat(hidden, nodeState.getChildNodeEntries());
Iterable cnes = IterableUtils.chainedIterable(hidden, nodeState.getChildNodeEntries());
when(before.getChildNodeEntries()).thenReturn(cnes);
when(before.getChildNode(":hidden")).thenReturn(child);

NodeState child2 = when(mock(NodeState.class).exists()).thenReturn(true).getMock();
hidden = Collections.singleton(new MemoryChildNodeEntry(":hidden", child2));
cnes = Iterables.concat(hidden, nodeState.getChildNodeEntries());
cnes = IterableUtils.chainedIterable(hidden, nodeState.getChildNodeEntries());
when(after.getChildNodeEntries()).thenReturn(cnes);
when(after.getChildNode(":hidden")).thenReturn(child2);

Expand All @@ -398,7 +399,7 @@ public void testHiddenChildNodeDeleted() {

NodeState child = mock(NodeState.class);
Iterable deletedCnes = Collections.singleton(new MemoryChildNodeEntry(":hidden", child));
Iterable cnes = Iterables.concat(deletedCnes, after.getChildNodeEntries());
Iterable cnes = IterableUtils.chainedIterable(deletedCnes, after.getChildNodeEntries());
when(before.getChildNodeEntries()).thenReturn(cnes);
when(before.getChildNode(":hidden")).thenReturn(child);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.List;
import java.util.Set;

import org.apache.commons.collections4.IterableUtils;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.oak.api.ContentSession;
Expand Down Expand Up @@ -87,7 +88,7 @@ public void before() throws Exception {
"/content/aa/bb" /* granted by ace, denied by cug */
);

for (String path : Iterables.concat(readAccess, noReadAccess)) {
for (String path : IterableUtils.chainedIterable(readAccess, noReadAccess)) {
addVersionContent(path);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.jackrabbit.oak.security.authorization.permission;

import org.apache.commons.collections4.IterableUtils;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList;
Expand Down Expand Up @@ -816,7 +817,7 @@ public void testHiddenChildNodeAdded() throws Exception {

NodeState child = mock(NodeState.class);
Iterable newCnes = Collections.singleton(new MemoryChildNodeEntry(":hidden", child));
Iterable cnes = Iterables.concat(newCnes, before.getChildNodeEntries());
Iterable cnes = IterableUtils.chainedIterable(newCnes, before.getChildNodeEntries());
when(after.getChildNodeEntries()).thenReturn(cnes);
when(after.getChildNode(":hidden")).thenReturn(child);

Expand All @@ -836,13 +837,13 @@ public void testHiddenChildNodeChanged() {

NodeState child = mock(NodeState.class);
Iterable hidden = Collections.singleton(new MemoryChildNodeEntry(":hidden", child));
Iterable cnes = Iterables.concat(hidden, nodeState.getChildNodeEntries());
Iterable cnes = IterableUtils.chainedIterable(hidden, nodeState.getChildNodeEntries());
when(before.getChildNodeEntries()).thenReturn(cnes);
when(before.getChildNode(":hidden")).thenReturn(child);

NodeState child2 = when(mock(NodeState.class).exists()).thenReturn(true).getMock();
hidden = Collections.singleton(new MemoryChildNodeEntry(":hidden", child2));
cnes = Iterables.concat(hidden, nodeState.getChildNodeEntries());
cnes = IterableUtils.chainedIterable(hidden, nodeState.getChildNodeEntries());
when(after.getChildNodeEntries()).thenReturn(cnes);
when(after.getChildNode(":hidden")).thenReturn(child2);

Expand All @@ -861,7 +862,7 @@ public void testHiddenChildNodeDeleted() {

NodeState child = mock(NodeState.class);
Iterable deletedCnes = Collections.singleton(new MemoryChildNodeEntry(":hidden", child));
Iterable cnes = Iterables.concat(deletedCnes, after.getChildNodeEntries());
Iterable cnes = IterableUtils.chainedIterable(deletedCnes, after.getChildNodeEntries());
when(before.getChildNodeEntries()).thenReturn(cnes);
when(before.getChildNode(":hidden")).thenReturn(child);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.jackrabbit.oak.security.user;

import org.apache.commons.collections4.IterableUtils;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.api.security.user.Authorizable;
Expand Down Expand Up @@ -72,7 +73,7 @@ public void after() throws Exception {
try {
clearInvocations(monitor);
root.refresh();
for (String path : Iterables.concat(testUsers, testGroups)) {
for (String path : IterableUtils.chainedIterable(testUsers, testGroups)) {
Authorizable auth = userMgr.getAuthorizableByPath(path);
if (auth != null) {
auth.remove();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.commons.collections4.IterableUtils;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.oak.api.PropertyState;
Expand Down Expand Up @@ -145,7 +147,7 @@ public void testNameNotDefinesProperty() {

@Test
public void testParentNotDefinesProperty() {
for (String propName : Iterables.concat(USER_PROPERTY_NAMES, GROUP_PROPERTY_NAMES)) {
for (String propName : IterableUtils.chainedIterable(USER_PROPERTY_NAMES, GROUP_PROPERTY_NAMES)) {
PropertyState property = PropertyStates.createProperty(propName, "value");

for (String ntName : new String[] {NodeTypeConstants.NT_OAK_UNSTRUCTURED, NT_REP_AUTHORIZABLE_FOLDER}) {
Expand Down Expand Up @@ -262,7 +264,7 @@ public void testNonExistingTreeDefinesLocation() {

@Test
public void testNonExistingTreeDefinesLocation2() {
for (String name : Iterables.concat(USER_PROPERTY_NAMES, GROUP_PROPERTY_NAMES)) {
for (String name : IterableUtils.chainedIterable(USER_PROPERTY_NAMES, GROUP_PROPERTY_NAMES)) {
String path = "/some/path/endingWith/reservedName/" + name;

for (String ntName : NT_NAMES) {
Expand All @@ -279,7 +281,7 @@ public void testNonExistingTreeDefinesLocation2() {

@Test
public void testNoTreeDefinesLocationReservedEnding() {
for (String name : Iterables.concat(USER_PROPERTY_NAMES, GROUP_PROPERTY_NAMES)) {
for (String name : IterableUtils.chainedIterable(USER_PROPERTY_NAMES, GROUP_PROPERTY_NAMES)) {
String path = "/some/path/endingWith/reservedName/" + name;
TreeLocation location = Mockito.mock(TreeLocation.class);
when(location.getPath()).thenReturn(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.jackrabbit.oak.security.user.action;

import org.apache.commons.collections4.IterableUtils;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.api.security.user.Group;
import org.apache.jackrabbit.api.security.user.User;
Expand Down Expand Up @@ -120,7 +121,7 @@ public void testMembersAdded() throws Exception {

Set<String> memberIds = Set.of(testUser01.getID());
Set<String> failedIds = Set.of(testUser02.getID(), testGroup.getID());
Iterable<String> ids = Iterables.concat(memberIds, failedIds);
Iterable<String> ids = IterableUtils.chainedIterable(memberIds, failedIds);

testGroup.addMembers(Iterables.toArray(ids, String.class));

Expand All @@ -143,7 +144,7 @@ public void testMembersRemoved() throws Exception {

Set<String> memberIds = Set.of(testUser01.getID());
Set<String> failedIds = Set.of(testUser02.getID(), testGroup.getID());
Iterable<String> ids = Iterables.concat(memberIds, failedIds);
Iterable<String> ids = IterableUtils.chainedIterable(memberIds, failedIds);

testGroup.removeMembers(Iterables.toArray(ids, String.class));
verify(groupAction, times(1)).onMembersRemoved(testGroup, memberIds, failedIds, root, getNamePathMapper());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import javax.jcr.security.AccessControlManager;
import javax.jcr.security.Privilege;

import org.apache.commons.collections4.IterableUtils;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.guava.common.collect.Iterators;
import org.apache.jackrabbit.api.JackrabbitSession;
Expand Down Expand Up @@ -125,14 +126,14 @@ public void heavyLoad() throws Throwable {
Session s = loginUser(repos.next());
observers.add(new Thread(new Observer(s, queueLength)));
}
for (Thread t : Iterables.concat(writers, readers, observers, loggers)) {
for (Thread t : IterableUtils.chainedIterable(writers, readers, observers, loggers)) {
t.start();
}
for (Thread t : Iterables.concat(writers, readers)) {
for (Thread t : IterableUtils.chainedIterable(writers, readers)) {
t.join();
}
LOG.info("Writes stopped. Waiting for observers...");
for (Thread t : Iterables.concat(observers, loggers)) {
for (Thread t : IterableUtils.chainedIterable(observers, loggers)) {
t.join();
}
for (Throwable t : exceptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

import javax.jcr.PropertyType;

import org.apache.commons.collections4.IterableUtils;
import org.apache.jackrabbit.guava.common.collect.ComparisonChain;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.guava.common.io.CountingInputStream;
Expand Down Expand Up @@ -1107,9 +1108,9 @@ public void sortQueriesWithStringIgnoredMulti_OrderedProps() throws Exception {
root.commit();

assertOrderedQuery("select [jcr:path] from [nt:base] where [bar] = 'baz' order by [foo]", ListUtils
.toList(Iterables.concat(List.of("/test/a"), getSortedPaths(tuples, OrderDirection.ASC))));
.toList(IterableUtils.chainedIterable(List.of("/test/a"), getSortedPaths(tuples, OrderDirection.ASC))));
assertOrderedQuery("select [jcr:path] from [nt:base] where [bar] = 'baz' order by [foo] DESC", ListUtils
.toList(Iterables.concat(getSortedPaths(tuples, OrderDirection.DESC), List.of("/test/a"))));
.toList(IterableUtils.chainedIterable(getSortedPaths(tuples, OrderDirection.DESC), List.of("/test/a"))));
}

void assertSortedString() throws CommitFailedException {
Expand Down Expand Up @@ -1197,10 +1198,10 @@ public void sortQueriesWithDateStringMixed_OrderedProps() throws Exception {

// Add the path of property added as timestamp string in the sorted list
assertOrderedQuery("select [jcr:path] from [nt:base] where [bar] = 'baz' order by [foo]", ListUtils
.toList(Iterables.concat(List.of("/test/n0"), getSortedPaths(tuples, OrderDirection.ASC))));
.toList(IterableUtils.chainedIterable(List.of("/test/n0"), getSortedPaths(tuples, OrderDirection.ASC))));
// Append the path of property added as timestamp string to the sorted list
assertOrderedQuery("select [jcr:path] from [nt:base] where [bar] = 'baz' order by [foo] DESC", ListUtils
.toList(Iterables.concat(getSortedPaths(tuples, OrderDirection.DESC), List.of("/test/n0"))));
.toList(IterableUtils.chainedIterable(getSortedPaths(tuples, OrderDirection.DESC), List.of("/test/n0"))));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.jackrabbit.oak.plugins.index.lucene.directory;

import org.apache.commons.collections4.IterableUtils;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.oak.InitialContentHelper;
import org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser;
Expand Down Expand Up @@ -124,7 +125,7 @@ public void concurrentPrefetch() throws Exception {

waitForLeechingCoRsToFinish();

for (Directory d : Iterables.concat(Collections.singleton(firstCoR), leechingCoRs)) {
for (Directory d : IterableUtils.chainedIterable(Collections.singleton(firstCoR), leechingCoRs)) {
IndexInput input = d.openInput("file", IOContext.READ);
assertFalse(d + " must not be reading from remote",
input.toString().startsWith(REMOTE_INPUT_PREFIX));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import javax.jcr.SimpleCredentials;
import javax.security.auth.Subject;

import org.apache.commons.collections4.IterableUtils;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.oak.api.AuthInfo;
import org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl;
Expand Down Expand Up @@ -128,7 +129,7 @@ public void testCreateFromSubjectWithAnyCredentials() {

@Test
public void testCreateFromPrincipalIterables() {
AuthInfo info = new AuthInfoImpl(USER_ID, ATTRIBUTES, Iterables.concat(PRINCIPALS, Collections.emptyList()));
AuthInfo info = new AuthInfoImpl(USER_ID, ATTRIBUTES, IterableUtils.chainedIterable(PRINCIPALS, Collections.emptyList()));
assertEquals(authInfo.toString(), info.toString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Set;
import java.util.TreeSet;

import org.apache.commons.collections4.IterableUtils;
import org.apache.jackrabbit.guava.common.collect.Iterables;

import org.apache.jackrabbit.api.security.principal.GroupPrincipal;
Expand Down Expand Up @@ -55,7 +56,7 @@ public class CompositePrincipalProviderTest {
private final PrincipalProvider cpp = CompositePrincipalProvider.of(List.<PrincipalProvider>of(pp1, pp2));

private Iterable<Principal> testPrincipals() {
return Iterables.concat(pp1.getTestPrincipals(), pp2.getTestPrincipals());
return IterableUtils.chainedIterable(pp1.getTestPrincipals(), pp2.getTestPrincipals());
}

private static void assertIterator(@NotNull Iterable<? extends Principal> expected, @NotNull Iterator<? extends Principal> result) {
Expand Down Expand Up @@ -136,7 +137,7 @@ public void findPrincipalsUnknown() {

@Test
public void findPrincipalsByTypeGroup() {
Iterable<? extends Principal> expected = Iterables.concat(Set.of(EveryonePrincipal.getInstance()), Iterables.filter(testPrincipals(),
Iterable<? extends Principal> expected = IterableUtils.chainedIterable(Set.of(EveryonePrincipal.getInstance()), Iterables.filter(testPrincipals(),
input -> input instanceof GroupPrincipal));

Iterator<? extends Principal> result = cpp.findPrincipals(PrincipalManager.SEARCH_TYPE_GROUP);
Expand All @@ -154,7 +155,7 @@ public void findPrincipalsByTypeNotGroup() {
@Test
public void findPrincipalsByTypeAll() {
Iterator<? extends Principal> result = cpp.findPrincipals(PrincipalManager.SEARCH_TYPE_ALL);
assertIterator(Iterables.concat(Set.of(EveryonePrincipal.getInstance()), testPrincipals()), result);
assertIterator(IterableUtils.chainedIterable(Set.of(EveryonePrincipal.getInstance()), testPrincipals()), result);
}

/**
Expand Down
Loading
Loading