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-11311: Remove usage of Guava ImmutableList #1909

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
92a3b8b
OAK-11311: Remove usage of Guava ImmutableList - oak-upgrade
reschke Dec 14, 2024
095bda6
OAK-11311: Remove usage of Guava ImmutableList - oak-upgrade
reschke Dec 14, 2024
3f48ee0
OAK-11311: Remove usage of Guava ImmutableList - oak-store-spi
reschke Dec 14, 2024
5075ce9
OAK-11311: Remove usage of Guava ImmutableList - oak-store-document -…
reschke Dec 15, 2024
fd3d69d
OAK-11311: Remove usage of Guava ImmutableList - oak-store-document
reschke Dec 16, 2024
9869b0d
OAK-11311: Remove usage of Guava ImmutableList - oak-store-document
reschke Dec 16, 2024
f9ecb61
OAK-11311: Remove usage of Guava ImmutableList - oak-authorization-cug
reschke Dec 16, 2024
ffd42cb
OAK-11311: Remove usage of Guava ImmutableList - oak-store-composite
reschke Dec 16, 2024
c2397bf
OAK-11311: Remove usage of Guava ImmutableList - oak-solr-cote
reschke Dec 16, 2024
9f20a7f
OAK-11311: Remove usage of Guava ImmutableList - oak-segment-tar
reschke Dec 16, 2024
427f3c4
OAK-11311: Remove usage of Guava ImmutableList - oak-segment-azure
reschke Dec 16, 2024
d078dea
OAK-11311: Remove usage of Guava ImmutableList - oak-security-spi - t…
reschke Dec 16, 2024
46fd54c
OAK-11311: Remove usage of Guava ImmutableList - oak-security-spi
reschke Dec 16, 2024
bde5761
Merge branch 'trunk' into OAK-11311
reschke Dec 17, 2024
ef231b9
OAK-11311: Remove usage of Guava ImmutableList - remove unintended ch…
reschke Dec 17, 2024
6385321
OAK-11311: Remove usage of Guava ImmutableList - oak-search
reschke Dec 17, 2024
e321c28
OAK-11311: Remove usage of Guava ImmutableList - oak-run-commons
reschke Dec 17, 2024
766def6
OAK-11311: Remove usage of Guava ImmutableList - oak-run-commons
reschke Dec 17, 2024
db0d499
OAK-11311: Remove usage of Guava ImmutableList - oak-run
reschke Dec 17, 2024
61c5bf5
OAK-11311: Remove usage of Guava ImmutableList - oak-query-spi
reschke Dec 17, 2024
e788bf2
Merge remote-tracking branch 'origin/trunk' into OAK-11311
reschke Dec 17, 2024
067ec3e
OAK-11311: Remove usage of Guava ImmutableList - oak-lucene
reschke Dec 19, 2024
5b2a863
OAK-11311: Remove usage of Guava ImmutableList - oak-search - remove …
reschke Dec 19, 2024
ffea376
OAK-11311: Remove usage of Guava ImmutableList - oak-store-document -…
reschke Dec 19, 2024
3b7c30a
OAK-11311: Remove usage of Guava ImmutableList - oak-security-spi - m…
reschke Dec 19, 2024
934c344
OAK-11311: Remove usage of Guava ImmutableList - oak-jcr
reschke Dec 19, 2024
1c5d4f1
OAK-11311: Remove usage of Guava ImmutableList - oak-it
reschke Dec 19, 2024
0083a8f
OAK-11311: Remove usage of Guava ImmutableList - oak-exercise
reschke Dec 19, 2024
76d6604
OAK-11311: Remove usage of Guava ImmutableList - oak-core-spi
reschke Dec 19, 2024
95c48a5
OAK-11311: Remove usage of Guava ImmutableList - oak-core tests
reschke Dec 20, 2024
0c827c3
OAK-11311: Remove usage of Guava ImmutableList - oak-core
reschke Dec 20, 2024
36b7820
OAK-11311: Remove usage of Guava ImmutableList - oak-commons
reschke Dec 20, 2024
b7b344d
OAK-11311: Remove usage of Guava ImmutableList - oak-blob-plugins
reschke Dec 20, 2024
6b71d93
OAK-11311: Remove usage of Guava ImmutableList - oak-blob-cloud
reschke Dec 20, 2024
6fc747f
OAK-11311: Remove usage of Guava ImmutableList - oak-benchmarks
reschke Dec 20, 2024
09955bd
OAK-11311: Remove usage of Guava ImmutableList - oak-authorization-pr…
reschke Dec 20, 2024
28a08b8
OAK-11311: Remove usage of Guava ImmutableList - oak-auth-external
reschke Dec 20, 2024
4670629
OAK-11311: Remove usage of Guava ImmutableList - oak-doc
reschke Dec 20, 2024
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 @@ -22,7 +22,7 @@
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
import org.jetbrains.annotations.NotNull;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import java.util.List;

/**
* Implementation of the {@code RepositoryInitializer} interface responsible for
Expand Down Expand Up @@ -54,12 +54,12 @@ public void initialize(@NotNull NodeBuilder builder) {
NodeBuilder index = IndexUtils.getOrCreateOakIndex(builder);
if (enforceUniqueIds && !index.hasChildNode("externalId")) {
NodeBuilder definition = IndexUtils.createIndexDefinition(index, "externalId", true, true,
ImmutableList.of(ExternalIdentityConstants.REP_EXTERNAL_ID), null);
List.of(ExternalIdentityConstants.REP_EXTERNAL_ID), null);
definition.setProperty("info", "Oak index assuring uniqueness of rep:externalId properties.");
}
if (!index.hasChildNode("externalPrincipalNames")) {
NodeBuilder definition = IndexUtils.createIndexDefinition(index, "externalPrincipalNames", true, false,
ImmutableList.of(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES), null);
List.of(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES), null);
definition.setProperty("info",
"Oak index used by the principal management provided by the external authentication module.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.api.security.principal.PrincipalManager;
import org.apache.jackrabbit.oak.api.Root;
import org.apache.jackrabbit.oak.namepath.NamePathMapper;
Expand Down Expand Up @@ -53,6 +52,7 @@
import org.osgi.service.metatype.annotations.Option;

import java.security.Principal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -182,7 +182,7 @@ public RepositoryInitializer getRepositoryInitializer() {
public List<? extends ValidatorProvider> getValidators(@NotNull String workspaceName, @NotNull Set<Principal> principals, @NotNull MoveTracker moveTracker) {
boolean isSystem = new SystemPrincipalConfig(getPrincipalNames()).containsSystemPrincipal(principals);

ImmutableList.Builder<ValidatorProvider> vps = new ImmutableList.Builder<>();
List<ValidatorProvider> vps = new ArrayList<>();
vps.add(new ExternalIdentityValidatorProvider(isSystem, protectedExternalIds()));

Set<String> idpNamesWithDynamicGroups = getIdpNamesWithDynamicGroups();
Expand All @@ -194,7 +194,7 @@ public List<? extends ValidatorProvider> getValidators(@NotNull String workspace
if (ipt != IdentityProtectionType.NONE && !isSystem) {
vps.add(new ExternalUserValidatorProvider(getRootProvider(), getTreeProvider(), getSecurityProvider(), ipt, getProtectionConfig()));
}
return vps.build();
return Collections.unmodifiableList(vps);
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.Iterables;
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.api.PropertyState;
Expand Down Expand Up @@ -44,6 +43,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import static org.apache.jackrabbit.oak.commons.conditions.Validate.checkArgument;
Expand Down Expand Up @@ -284,13 +285,13 @@ private static final class AggregatedContext extends Context.Default {
List<Context> ctxs;

private AggregatedContext(@NotNull SecurityProvider securityProvider) {
ImmutableList.Builder<Context> builder = ImmutableList.builder();
List<Context> builder = new ArrayList<>();
for (SecurityConfiguration sc : securityProvider.getConfigurations()) {
if (!UserConfiguration.NAME.equals(sc.getName())) {
builder.add(sc.getContext());
}
}
ctxs = builder.build();
ctxs = Collections.unmodifiableList(builder);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
package org.apache.jackrabbit.oak.spi.security.authentication.external;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.junit.Test;
Expand Down Expand Up @@ -169,7 +168,7 @@ public Iterable<ExternalIdentityRef> getDeclaredGroups() {

@Test
public void testToString() {
for (ExternalIdentityRef r : ImmutableList.of(ref, refEmptyProvider, refEmptyProvider)) {
for (ExternalIdentityRef r : List.of(ref, refEmptyProvider, refEmptyProvider)) {
assertEquals("ExternalIdentityRef{" + "id='" + r.getId() + '\'' + ", providerName='" + r.getProviderName() + '\'' + '}', r.toString());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;
Expand All @@ -29,8 +30,6 @@
import javax.jcr.SimpleCredentials;
import javax.security.auth.login.LoginException;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;

import org.apache.jackrabbit.guava.common.collect.ImmutableSet;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -76,7 +75,7 @@ public TestIdentityProvider(@NotNull String idpName) {
addUser(new TestUser(ID_SECOND_USER, getName())
.withProperty("profile/name", "Second User")
.withProperty("age", 24)
.withProperty("col", ImmutableList.of("v1", "v2", "v3"))
.withProperty("col", List.of("v1", "v2", "v3"))
.withProperty("boolArr", new Boolean[]{true, false})
.withProperty("charArr", new char[]{'t', 'o', 'b'})
.withProperty("byteArr", new byte[0])
Expand Down Expand Up @@ -284,7 +283,7 @@ public ForeignExternalGroup() {
@NotNull
@Override
public Iterable<ExternalIdentityRef> getDeclaredMembers() {
return ImmutableList.of();
return List.of();
}
}

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

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.api.security.user.Authorizable;
import org.apache.jackrabbit.api.security.user.Group;
Expand Down Expand Up @@ -1451,7 +1450,7 @@ public void testCreateValueFromInputStream() throws Exception {

@Test
public void testCreateValuesEmptyCollection() throws Exception {
Value[] vs = syncCtx.createValues(ImmutableList.of());
Value[] vs = syncCtx.createValues(List.of());
assertNotNull(vs);
assertEquals(0, vs.length);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
*/
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;
Expand All @@ -36,6 +35,7 @@
import java.security.Principal;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;

import static org.junit.Assert.assertSame;

Expand Down Expand Up @@ -116,17 +116,17 @@ protected void sync(@NotNull ExternalIdentity externalIdentity, @NotNull SyncRes

@NotNull
static List<String> getIds(@NotNull Iterator<? extends Authorizable> authorizables) {
return ImmutableList.copyOf(Iterators.transform(authorizables, authorizable -> {
return CollectionUtils.toStream(authorizables).map(authorizable -> {
try {
return authorizable.getID();
} catch (RepositoryException repositoryException) {
throw new RuntimeException();
}
}));
}).collect(Collectors.toList());
}

@NotNull
static List<String> getPrincipalNames(@NotNull Iterator<Principal> groupPrincipals) {
return ImmutableList.copyOf(Iterators.transform(groupPrincipals, Principal::getName));
return CollectionUtils.toStream(groupPrincipals).map(Principal::getName).collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import javax.jcr.SimpleCredentials;
import javax.security.auth.login.LoginException;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.oak.api.AuthInfo;
import org.apache.jackrabbit.oak.api.ContentSession;
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup;
Expand Down Expand Up @@ -71,7 +70,7 @@ public void testLogin() throws Exception {

@Test
public void testLoginWithUnsupportedCredentials() throws Exception {
List<Credentials> creds = ImmutableList.of(
List<Credentials> creds = List.of(
new SimpleCredentials("testUser", new char[0]),
new GuestCredentials());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@
*/
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;
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;
Expand Down Expand Up @@ -294,7 +292,7 @@ public void testCrossIDPMembership() throws Exception {
UserManager um = getUserManager(r);
PrincipalManager pm = getPrincipalManager(r);

List<ExternalIdentityRef> declaredGroupRefs = ImmutableList.copyOf(previouslySyncedUser.getDeclaredGroups());
List<ExternalIdentityRef> declaredGroupRefs = CollectionUtils.toList(previouslySyncedUser.getDeclaredGroups());
assertTrue(declaredGroupRefs.size() > 1);

String groupId = declaredGroupRefs.get(0).getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +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.Iterables;
import org.apache.jackrabbit.guava.common.collect.Iterators;
import org.apache.jackrabbit.api.security.user.Authorizable;
Expand Down Expand Up @@ -47,6 +46,7 @@

import javax.jcr.RepositoryException;
import javax.jcr.Value;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -119,7 +119,7 @@ protected void assertDynamicMembership(@NotNull ExternalIdentity externalIdentit

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 = Arrays.stream(vs).map(value -> {
try {
return value.getString();
} catch (RepositoryException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.Iterators;
import org.apache.jackrabbit.api.security.user.Group;
import org.apache.jackrabbit.api.security.user.User;
Expand Down Expand Up @@ -141,7 +140,7 @@ public void testAddMembersProperty() throws Exception {
assertFalse(groupTree.hasProperty(REP_MEMBERS));

String uuid = r.getTree(userManager.getAuthorizable(USER_ID).getPath()).getProperty(JCR_UUID).getValue(Type.STRING);
groupTree.setProperty(REP_MEMBERS, ImmutableList.of(uuid), Type.WEAKREFERENCES);
groupTree.setProperty(REP_MEMBERS, List.of(uuid), Type.WEAKREFERENCES);
try {
r.commit();
fail("CommitFailedException 77 expected.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,6 +28,7 @@
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;
Expand Down Expand Up @@ -593,7 +593,7 @@ public Iterator<? extends Principal> findPrincipals(@Nullable String nameHint, i
return in.iterator();
}
};
List<Principal> out = ImmutableList.copyOf(p.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_ALL, 0, -1));
List<Principal> out = CollectionUtils.toList(p.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_ALL, 0, -1));
Collections.sort(in, Comparator.comparing(Principal::getName));
assertEquals(in, out);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.Iterables;
import org.apache.jackrabbit.api.security.principal.GroupPrincipal;
import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal;
Expand All @@ -26,6 +25,7 @@
import org.apache.jackrabbit.oak.api.QueryEngine;
import org.apache.jackrabbit.oak.api.Root;
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.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;
Expand All @@ -38,7 +38,9 @@
import java.security.Principal;
import java.text.ParseException;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static org.apache.jackrabbit.oak.spi.security.authentication.external.TestIdentityProvider.ID_SECOND_USER;
import static org.apache.jackrabbit.oak.spi.security.authentication.external.impl.ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES;
Expand Down Expand Up @@ -69,18 +71,19 @@ public void testNotIsMember() throws Exception {
Authorizable notMember = getUserManager(root).getAuthorizable(ID_SECOND_USER);
assertFalse(principal.isMember(notMember.getPrincipal()));

root.getTree(notMember.getPath()).setProperty(REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of("secondGroup"), Type.STRINGS);
root.getTree(notMember.getPath()).setProperty(REP_EXTERNAL_PRINCIPAL_NAMES, List.of("secondGroup"), Type.STRINGS);
assertFalse(principal.isMember(notMember.getPrincipal()));

root.getTree(notMember.getPath()).setProperty(REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of(), Type.STRINGS);
root.getTree(notMember.getPath()).setProperty(REP_EXTERNAL_PRINCIPAL_NAMES, List.of(), Type.STRINGS);
assertFalse(principal.isMember(new PrincipalImpl(notMember.getPrincipal().getName())));
}

@Test
public void testIsMemberExternalGroup() throws Exception {
GroupPrincipal principal = getGroupPrincipal();

Iterable<String> exGroupPrincNames = Iterables.transform(ImmutableList.copyOf(idp.listGroups()), ExternalIdentity::getPrincipalName);
List<String> exGroupPrincNames = CollectionUtils.toStream(
idp.listGroups()).map(ExternalIdentity::getPrincipalName).collect(Collectors.toList());
for (String principalName : exGroupPrincNames) {
assertFalse(principal.isMember(new PrincipalImpl(principalName)));
}
Expand Down
Loading
Loading