Skip to content

Commit

Permalink
OAK-11311: Remove usage of Guava ImmutableList - oak-core
Browse files Browse the repository at this point in the history
  • Loading branch information
reschke committed Dec 20, 2024
1 parent 95c48a5 commit 0c827c3
Show file tree
Hide file tree
Showing 18 changed files with 52 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.Root;
Expand All @@ -45,8 +46,6 @@
import org.apache.jackrabbit.oak.spi.version.VersionConstants;
import org.jetbrains.annotations.NotNull;

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

/**
* {@code InitialContent} implements a {@link RepositoryInitializer} the creates
* the initial JCR/Oak repository structure. This includes creating
Expand Down Expand Up @@ -96,11 +95,11 @@ public void initialize(@NotNull NodeBuilder builder) {
NodeBuilder index = IndexUtils.getOrCreateOakIndex(builder);

NodeBuilder uuid = IndexUtils.createIndexDefinition(index, "uuid", true, true,
ImmutableList.<String>of(JCR_UUID), null);
List.of(JCR_UUID), null);
uuid.setProperty("info",
"Oak index for UUID lookup (direct lookup of nodes with the mixin 'mix:referenceable').");
NodeBuilder nodetype = IndexUtils.createIndexDefinition(index, "nodetype", true, false,
ImmutableList.of(JCR_PRIMARYTYPE, JCR_MIXINTYPES), null);
List.of(JCR_PRIMARYTYPE, JCR_MIXINTYPES), null);
nodetype.setProperty("info",
"Oak index for queries with node type, and possibly path restrictions, " +
"for example \"/jcr:root/content//element(*, mix:language)\".");
Expand Down
11 changes: 5 additions & 6 deletions oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import javax.management.StandardMBean;
import javax.security.auth.login.LoginException;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.guava.common.io.Closer;

Expand Down Expand Up @@ -1037,20 +1036,20 @@ public static class OakDefaultComponents {
@Deprecated
public static final OakDefaultComponents INSTANCE = new OakDefaultComponents();

private final Iterable<CommitHook> commitHooks = ImmutableList.of(new VersionHook());
private final Iterable<CommitHook> commitHooks = List.of(new VersionHook());

private final Iterable<RepositoryInitializer> repositoryInitializers = ImmutableList
private final Iterable<RepositoryInitializer> repositoryInitializers = List
.of(new InitialContent());

private final Iterable<EditorProvider> editorProviders = ImmutableList.of(
private final Iterable<EditorProvider> editorProviders = List.of(
new ItemSaveValidatorProvider(), new NameValidatorProvider(), new NamespaceEditorProvider(),
new TypeEditorProvider(), new ConflictValidatorProvider(), new ChangeCollectorProvider());

private final Iterable<IndexEditorProvider> indexEditorProviders = ImmutableList.of(
private final Iterable<IndexEditorProvider> indexEditorProviders = List.of(
new ReferenceEditorProvider(), new PropertyIndexEditorProvider(), new NodeCounterEditorProvider(),
new OrderedPropertyIndexEditorProvider());

private final Iterable<QueryIndexProvider> queryIndexProviders = ImmutableList
private final Iterable<QueryIndexProvider> queryIndexProviders = List
.of(new ReferenceIndexProvider(), new PropertyIndexProvider(), new NodeTypeIndexProvider());

private final SecurityProvider securityProvider = SecurityProviderBuilder.newBuilder().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.codahale.metrics.Counter;
import com.codahale.metrics.Metric;
import com.codahale.metrics.MetricRegistry;
import org.apache.jackrabbit.guava.common.collect.ImmutableList;

import org.apache.jackrabbit.oak.api.jmx.CacheStatsMBean;
import org.osgi.service.component.annotations.Component;
Expand All @@ -51,7 +50,7 @@ public class CacheStatsMetrics {
static final String ELEMENT = "element";
static final String LOAD_TIME = "loadTime";

private static final List<String> TYPES = ImmutableList.of(
private static final List<String> TYPES = List.of(
REQUEST, HIT, MISS, EVICTION, ELEMENT, LOAD_TIME);

private Map<String, CacheStatsMBean> cacheStatsMBeans = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import org.apache.jackrabbit.oak.spi.commit.CompositeConflictHandler;
import org.apache.jackrabbit.oak.spi.commit.ConflictHandlers;

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


/**
* Utility class providing conflict handlers used for JCR.
Expand All @@ -34,7 +35,7 @@ public final class JcrConflictHandler {
* and {@link AnnotatingConflictHandler}.
*/
public static CompositeConflictHandler createJcrConflictHandler() {
return new CompositeConflictHandler(ImmutableList.of(
return new CompositeConflictHandler(List.of(
new JcrLastModifiedConflictHandler(),
ConflictHandlers.wrap(new ChildOrderConflictHandler()),
new AnnotatingConflictHandler()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
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.
*/
Expand All @@ -50,7 +48,7 @@ public Editor getIndexEditor(
return providers.iterator().next();
} else {
return new CompositeIndexEditorProvider(
ImmutableList.copyOf(providers));
List.copyOf(providers));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.TYPE_PROPERTY_NAME;
import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.UNIQUE_PROPERTY_NAME;

import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.LinkedHashMap;
Expand All @@ -42,7 +44,6 @@

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;
Expand Down Expand Up @@ -131,7 +132,7 @@ public static Tree createIndexDefinition(@NotNull Tree indexNode,
@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, Arrays.asList(propertyNames), Arrays.asList(declaringNodeTypeNames), PropertyIndexEditorProvider.TYPE, null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
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;
Expand Down Expand Up @@ -76,7 +76,7 @@ public void print(PrintWriter pw, Format format, boolean isZip) {
}

private void asyncLanesInfo(PrinterOutput po) {
List<String> asyncLanes = ImmutableList.copyOf(asyncIndexInfoService.getAsyncLanes());
List<String> asyncLanes = CollectionUtils.toList(asyncIndexInfoService.getAsyncLanes());
po.startSection("Async Indexers State", true);
po.text("Number of async indexer lanes", asyncLanes.size());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.apache.jackrabbit.oak.spi.state.NodeState;
import org.jetbrains.annotations.NotNull;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

Expand All @@ -45,7 +44,7 @@ public class NodeTypeIndexProvider implements QueryIndexProvider {
@NotNull
@Override
public List<? extends QueryIndex> getQueryIndexes(NodeState nodeState) {
return ImmutableList.of(new NodeTypeIndex(mountInfoProvider));
return List.of(new NodeTypeIndex(mountInfoProvider));
}

public NodeTypeIndexProvider with(MountInfoProvider mountInfoProvider) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.jackrabbit.oak.spi.state.NodeState;
import org.jetbrains.annotations.NotNull;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

Expand All @@ -45,7 +44,7 @@ public class PropertyIndexProvider implements QueryIndexProvider {

@Override @NotNull
public List<QueryIndex> getQueryIndexes(NodeState state) {
return ImmutableList.<QueryIndex>of(new PropertyIndex(mountInfoProvider));
return List.of(new PropertyIndex(mountInfoProvider));
}

public PropertyIndexProvider with(MountInfoProvider mountInfoProvider) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.jackrabbit.oak.spi.state.NodeState;
import org.jetbrains.annotations.NotNull;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

Expand All @@ -41,7 +40,7 @@ public class ReferenceIndexProvider implements QueryIndexProvider {
@Override
@NotNull
public List<QueryIndex> getQueryIndexes(NodeState state) {
return ImmutableList.<QueryIndex> of(new ReferenceIndex(mountInfoProvider));
return List.of(new ReferenceIndex(mountInfoProvider));
}

public ReferenceIndexProvider with(MountInfoProvider mountInfoProvider) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import java.util.function.Predicate;
import java.util.regex.Pattern;

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.plugins.nodetype.TypePredicate;
Expand Down Expand Up @@ -127,7 +126,7 @@ public FilterBuilder addPathsForMBean(@NotNull Set<String> paths) {
*/
@NotNull
private Iterable<String> getSubTrees() {
return subTrees.isEmpty() ? ImmutableList.of("/") : subTrees;
return subTrees.isEmpty() ? List.of("/") : subTrees;
}

public FilterBuilder aggregator(EventAggregator aggregator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.Set;
import javax.jcr.RepositoryException;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.Root;
Expand Down Expand Up @@ -436,7 +435,7 @@ private void createVersion(@NotNull NodeBuilder vHistory,

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.toList(state.getValue(Type.REFERENCES));
NodeBuilder version = vHistory.child(calculateVersion(vHistory, versionable));

String versionUUID = UUIDUtils.generateUUID();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.slf4j.LoggerFactory;

import org.apache.jackrabbit.guava.common.collect.AbstractIterator;
import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.Iterators;
import org.apache.jackrabbit.guava.common.collect.PeekingIterator;

Expand Down Expand Up @@ -329,7 +328,7 @@ public Iterator<ResultRowImpl> getRows() {
} else {
// This would suggest either the sub queries are sorted by index or explicitly by QueryImpl (in case of traversing index)
// So use mergeSorted here.
it = Iterators.mergeSorted(ImmutableList.of(leftIter, rightIter), orderBy);
it = Iterators.mergeSorted(List.of(leftIter, rightIter), orderBy);
}

it = FilterIterators.newCombinedFilter(it, distinct, limit.orElse(Long.MAX_VALUE), offset.orElse(0L), null, settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.oak.security.authentication.token;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.ImmutableSet;
import org.apache.jackrabbit.oak.api.Root;
import org.apache.jackrabbit.oak.spi.commit.MoveTracker;
Expand Down Expand Up @@ -146,7 +145,7 @@ public String getName() {
@Override
public List<? extends ValidatorProvider> getValidators(@NotNull String workspaceName, @NotNull Set<Principal> principals, @NotNull MoveTracker moveTracker) {
ValidatorProvider vp = new TokenValidatorProvider(getSecurityProvider().getParameters(UserConfiguration.NAME), getTreeProvider());
return ImmutableList.of(vp);
return List.of(vp);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.Set;
import javax.jcr.security.AccessControlManager;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.oak.api.Root;
import org.apache.jackrabbit.oak.namepath.NamePathMapper;
import org.apache.jackrabbit.oak.security.authorization.monitor.AuthorizationMonitor;
Expand Down Expand Up @@ -159,15 +158,15 @@ public WorkspaceInitializer getWorkspaceInitializer() {
@NotNull
@Override
public List<? extends CommitHook> getCommitHooks(@NotNull String workspaceName) {
return ImmutableList.of(
return List.of(
new VersionablePathHook(workspaceName, this),
new PermissionHook(workspaceName, getRestrictionProvider(), this));
}

@NotNull
@Override
public List<ValidatorProvider> getValidators(@NotNull String workspaceName, @NotNull Set<Principal> principals, @NotNull MoveTracker moveTracker) {
return ImmutableList.of(
return List.of(
new PermissionStoreValidatorProvider(),
new PermissionValidatorProvider(workspaceName, principals, moveTracker, this),
new AccessControlValidatorProvider(this));
Expand All @@ -176,7 +175,7 @@ public List<ValidatorProvider> getValidators(@NotNull String workspaceName, @Not
@NotNull
@Override
public List<ProtectedItemImporter> getProtectedItemImporters() {
return ImmutableList.of(new AccessControlImporter());
return List.of(new AccessControlImporter());
}

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

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

import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.plugins.index.IndexUtils;
Expand Down Expand Up @@ -56,8 +57,8 @@ public void initialize(NodeBuilder builder, String workspaceName) {
NodeBuilder index = IndexUtils.getOrCreateOakIndex(builder);
if (!index.hasChildNode("acPrincipalName")) {
NodeBuilder acPrincipalName = IndexUtils.createIndexDefinition(index, "acPrincipalName", true, false,
ImmutableList.<String>of(REP_PRINCIPAL_NAME),
ImmutableList.<String>of(NT_REP_DENY_ACE, NT_REP_GRANT_ACE, NT_REP_ACE));
List.of(REP_PRINCIPAL_NAME),
List.of(NT_REP_DENY_ACE, NT_REP_GRANT_ACE, NT_REP_ACE));
acPrincipalName.setProperty("info", "Oak index used by authorization to quickly search a principal by name.");
}

Expand Down
Loading

0 comments on commit 0c827c3

Please sign in to comment.