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-11023: Remove usage of Guava newArrayList #1839

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
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 @@ -51,7 +51,6 @@

import org.apache.jackrabbit.guava.common.base.Splitter;

import org.apache.jackrabbit.guava.common.collect.Lists;
import org.apache.jackrabbit.guava.common.collect.Maps;

/**
Expand Down Expand Up @@ -123,11 +122,9 @@ public class ScalabilityNodeRelationshipSuite extends ScalabilityNodeSuite {

private static final long BUCKET_SIZE = 100;

private static final List<String> actions = Lists
.newArrayList("act1", "act2", "act3", "act4", "act5", "act6", "act7", "act8", "act9",
private static final List<String> actions = List.of("act1", "act2", "act3", "act4", "act5", "act6", "act7", "act8", "act9",
"act10");
private static final List<String> objects = Lists
.newArrayList("obj1", "obj2", "obj3", "obj4", "obj5", "obj6", "obj7", "obj8", "obj9",
private static final List<String> objects = List.of("obj1", "obj2", "obj3", "obj4", "obj5", "obj6", "obj7", "obj8", "obj9",
"obj10");

private final Random random = new Random(29);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.apache.jackrabbit.oak.benchmark.authorization;

import org.apache.jackrabbit.guava.common.collect.ImmutableSet;
import org.apache.jackrabbit.guava.common.collect.Lists;
import org.apache.jackrabbit.api.JackrabbitSession;
import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager;
import org.apache.jackrabbit.api.security.user.Group;
Expand All @@ -36,6 +35,7 @@
import javax.jcr.security.Privilege;
import javax.security.auth.Subject;
import java.security.Principal;
import java.util.Arrays;
import java.util.List;
import java.util.Set;

Expand Down Expand Up @@ -82,7 +82,7 @@ protected void beforeSuite() throws Exception {
Utils.addEntry(acMgr, principal, PathUtils.ROOT_PATH, readPrivs);

// create additional ACEs according to benchmark configuration
allPrivileges = Lists.newArrayList(acMgr.privilegeFromName(JCR_ALL).getAggregatePrivileges());
allPrivileges = Arrays.asList(acMgr.privilegeFromName(JCR_ALL).getAggregatePrivileges());
createForEachPrincipal(principal, acMgr, allPrivileges);

adminSession.save();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.apache.jackrabbit.oak.benchmark.authorization.permission;

import org.apache.jackrabbit.guava.common.collect.Iterators;
import org.apache.jackrabbit.guava.common.collect.Lists;
import org.apache.jackrabbit.api.JackrabbitSession;
import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager;
import org.apache.jackrabbit.api.security.user.User;
Expand All @@ -44,6 +43,7 @@
import javax.jcr.security.Privilege;
import javax.security.auth.Subject;
import java.security.Principal;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -103,7 +103,7 @@ protected void beforeSuite() throws Exception {
Utils.addEntry(acMgr, principal, PathUtils.ROOT_PATH, readPrivs);

// create additional ACEs for each principal in the subject
List<Privilege> allPrivileges = Lists.newArrayList(acMgr.privilegeFromName(JCR_ALL).getAggregatePrivileges());
List<Privilege> allPrivileges = Arrays.asList(acMgr.privilegeFromName(JCR_ALL).getAggregatePrivileges());
Iterator<Principal> principalIterator = Iterators.cycle(subject.getPrincipals());
int cnt = 0;
while (cnt < numberOfACEs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.apache.jackrabbit.guava.common.collect.ImmutableMap;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.guava.common.collect.Iterators;
import org.apache.jackrabbit.guava.common.collect.Lists;
import org.apache.jackrabbit.api.JackrabbitSession;
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList;
import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager;
Expand Down Expand Up @@ -54,6 +53,7 @@
import javax.jcr.security.Privilege;
import javax.security.auth.Subject;
import java.security.Principal;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -111,7 +111,7 @@ protected void beforeSuite() throws Exception {
}

// create additional ACEs according to benchmark configuration
List<Privilege> allPrivileges = Lists.newArrayList(acMgr.privilegeFromName(JCR_ALL).getAggregatePrivileges());
List<Privilege> allPrivileges = Arrays.asList(acMgr.privilegeFromName(JCR_ALL).getAggregatePrivileges());
if (!entriesForEachPrincipal) {
createForRotatingPrincipal(acMgr, allPrivileges);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static java.util.Comparator.comparing;
import static java.util.Objects.requireNonNull;
import static org.apache.commons.io.FileUtils.copyFile;
import static org.apache.jackrabbit.guava.common.collect.Lists.newArrayList;
import static org.apache.jackrabbit.oak.commons.FileIOUtils.copy;
import static org.apache.jackrabbit.oak.commons.FileIOUtils.merge;
import static org.apache.jackrabbit.oak.commons.FileIOUtils.sort;
Expand All @@ -39,6 +38,7 @@
import java.sql.Timestamp;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
Expand Down Expand Up @@ -1058,7 +1058,7 @@ long sweepInternal(GarbageCollectableBlobStore blobStore, List<String> ids,
LOG.trace("Blob ids to be deleted {}", ids);
for (String id : ids) {
try {
long deleted = blobStore.countDeleteChunks(newArrayList(id), maxModified);
long deleted = blobStore.countDeleteChunks(new ArrayList<>(Arrays.asList(id)), maxModified);
if (deleted != 1) {
LOG.debug("Blob [{}] not deleted", id);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
Expand Down Expand Up @@ -394,7 +396,7 @@ private ActiveDeletionTracker() {}
public void track(File recs) throws IOException {
lock.lock();
try {
append(Lists.newArrayList(recs), delFile, false);
append(new ArrayList<>(Arrays.asList(recs)), delFile, false);
sort(delFile);
} finally {
lock.unlock();
Expand Down Expand Up @@ -688,7 +690,7 @@ protected void addRecords(Iterator<String> recs) throws IOException {
File added = createTempFile("added", null);
writeStrings(recs, added, false);
// Merge the file with the references
merge(Lists.newArrayList(added), false);
merge(new ArrayList<>(Arrays.asList(added)), false);
}

/**
Expand All @@ -699,7 +701,7 @@ protected void addRecords(Iterator<String> recs) throws IOException {
*/
protected void addRecords(File recs) throws IOException {
// Merge the file with the references
merge(Lists.newArrayList(recs), false);
merge(new ArrayList<>(Arrays.asList(recs)), false);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.jackrabbit.oak.plugins.observation.filter;

import static java.util.Objects.requireNonNull;
import static org.apache.jackrabbit.guava.common.collect.Lists.newArrayList;
import static javax.jcr.observation.Event.NODE_ADDED;
import static javax.jcr.observation.Event.NODE_MOVED;
import static javax.jcr.observation.Event.NODE_REMOVED;
Expand All @@ -30,6 +29,7 @@
import static org.apache.jackrabbit.oak.commons.PathUtils.isAncestor;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -342,7 +342,7 @@ public Condition moveSubtree() {
*/
@NotNull
public Condition any(@NotNull Condition... conditions) {
return new AnyCondition(newArrayList(requireNonNull(conditions)));
return new AnyCondition(new ArrayList<>(Arrays.asList(requireNonNull(conditions))));
}
/**
* A compound condition that holds when all of its constituents hold.
Expand All @@ -352,7 +352,7 @@ public Condition any(@NotNull Condition... conditions) {
*/
@NotNull
public Condition all(@NotNull Condition... conditions) {
return new AllCondition(newArrayList(requireNonNull(conditions)));
return new AllCondition(new ArrayList<>(Arrays.asList(requireNonNull(conditions))));
}

/**
Expand Down Expand Up @@ -603,7 +603,7 @@ public AnyCondition(Iterable<Condition> conditions) {
}

public AnyCondition(Condition... conditions) {
this(newArrayList(conditions));
this(new ArrayList<>(Arrays.asList(conditions)));
}

@Override
Expand All @@ -630,7 +630,7 @@ public AllCondition(Iterable<Condition> conditions) {
}

public AllCondition(Condition... conditions) {
this(newArrayList(conditions));
this(new ArrayList<>(Arrays.asList(conditions)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
import static org.apache.jackrabbit.oak.plugins.observation.filter.ConstantFilter.INCLUDE_ALL;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

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

import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.spi.state.NodeState;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -101,7 +100,7 @@ public EventFilter create(String name, NodeState before, NodeState after) {
*/
@NotNull
public static EventFilter any(@NotNull final EventFilter... filters) {
return any(Lists.newArrayList(requireNonNull(filters)));
return any(new ArrayList<>(Arrays.asList(requireNonNull(filters))));
}

/**
Expand All @@ -112,7 +111,7 @@ public static EventFilter any(@NotNull final EventFilter... filters) {
*/
@NotNull
public static EventFilter all(@NotNull final EventFilter... filters) {
return all(Lists.newArrayList(requireNonNull(filters)));
return all(new ArrayList<>(Arrays.asList(requireNonNull(filters))));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions oak-doc/src/site/markdown/security/user/groupaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ added to or removed from a specific group:
}

private void createHome(Group group, Root root, String memberId, NamePathMapper namePathMapper) throws RepositoryException {
createHome(group, root, Lists.newArrayList(memberId), Lists.<String>newArrayList(), namePathMapper);
createHome(group, root, Arrays.asList(memberId), new ArrayList<>(), namePathMapper);
}

private void createHome(Group group, Root root, Iterable<String> memberIds, Iterable<String> failedIds, NamePathMapper namePathMapper) throws RepositoryException {
Expand All @@ -129,7 +129,7 @@ added to or removed from a specific group:
}

private void removeHome(Group group, Root root, String memberId, NamePathMapper namePathMapper) {
removeHome(group, root, Lists.newArrayList(memberId), Lists.<String>newArrayList(), namePathMapper);
removeHome(group, root, Arrays.asList(memberId), new ArrayList<>(), namePathMapper);
}

private void removeHome(Group group, Root root, Iterable<String> memberIds, Iterable<String> failedIds, NamePathMapper namePathMapper) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import java.io.IOException;
import java.security.SecureRandom;
import java.util.Collection;
import java.util.List;
import java.util.Set;

import org.apache.jackrabbit.guava.common.collect.ImmutableSet;
import org.apache.jackrabbit.guava.common.collect.Lists;
import org.apache.jackrabbit.guava.common.collect.Sets;
import org.apache.jackrabbit.oak.api.Blob;
import org.apache.jackrabbit.oak.api.PropertyState;
Expand Down Expand Up @@ -167,7 +167,7 @@ public void deleteFile(String name) throws IOException {
// OAK-7066: Also, make sure that we have at least some non-inlined chunks to delete
if (blobId != null && !InMemoryDataRecord.isInstance(blobId)) {
blobDeletionCallback.deleted(blobId,
Lists.newArrayList(definition.getIndexPath(), dataNodeName, name));
List.of(definition.getIndexPath(), dataNodeName, name));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import javax.jcr.Node
import javax.jcr.Session
import javax.jcr.query.*

import static org.apache.jackrabbit.guava.common.collect.Lists.newArrayList
import static org.apache.jackrabbit.JcrConstants.JCR_CONTENT
import static org.apache.jackrabbit.JcrConstants.NT_FILE
import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NAME
Expand Down Expand Up @@ -72,7 +71,7 @@ class LuceneSupportTest extends AbstractRepositoryFactoryTest {
session.save()

SimpleNodeAggregator agg = new SimpleNodeAggregator().newRuleWithName(
NT_FILE, newArrayList(JCR_CONTENT, JCR_CONTENT + "/*"));
NT_FILE, new ArrayList<>(Arrays.asList(JCR_CONTENT, JCR_CONTENT + "/*")));
getRegistry ( ).registerService ( QueryIndex.NodeAggregator.class.name, agg, null )

//The lucene index is set to synched mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.jackrabbit.oak.console.commands

import org.apache.jackrabbit.guava.common.collect.Iterables
import org.apache.jackrabbit.guava.common.collect.Lists
import jline.console.completer.Completer
import org.apache.jackrabbit.oak.commons.PathUtils
import org.apache.jackrabbit.oak.console.ConsoleSession
Expand Down Expand Up @@ -67,7 +66,7 @@ class CdCommand extends CommandSupport{
} else {
path = PathUtils.concat(session.getWorkingPath(), arg);
}
List<String> elements = Lists.newArrayList();
List<String> elements = new ArrayList<>(Arrays.asList());
PathUtils.elements(path).each{String element ->
if (PathUtils.denotesParent(element)) {
if (!elements.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
Expand All @@ -26,7 +27,6 @@
import org.apache.jackrabbit.oak.commons.TimeDurationFormatter;
import org.apache.jackrabbit.oak.plugins.document.util.Utils;

import static org.apache.jackrabbit.guava.common.collect.Lists.newArrayList;
import static org.apache.jackrabbit.oak.plugins.document.Collection.JOURNAL;
import static org.apache.jackrabbit.oak.plugins.document.Collection.NODES;
import static org.apache.jackrabbit.oak.plugins.document.UpdateOp.Operation.Type.REMOVE_MAP_ENTRY;
Expand Down Expand Up @@ -75,7 +75,7 @@ public void sweepUpdate(Map<Path, UpdateOp> updates)
entry.invalidate(Collections.singleton(r));
Revision jRev = context.newRevision();
UpdateOp jOp = entry.asUpdateOp(jRev);
if (!store.create(JOURNAL, newArrayList(invOp, jOp))) {
if (!store.create(JOURNAL, List.of(invOp, jOp))) {
String msg = "Unable to create journal entries for " +
"document invalidation.";
throw new DocumentStoreException(msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
* limitations under the License.
*
*/

package org.apache.jackrabbit.oak.segment.file.proc;

import static java.util.Collections.emptySet;
import static java.util.Collections.singleton;

import org.apache.jackrabbit.guava.common.collect.Lists;
import java.util.Arrays;

import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState;
Expand Down Expand Up @@ -50,7 +50,7 @@ public Iterable<? extends PropertyState> getProperties() {
}

private Iterable<PropertyState> getProperties(Commit entry) {
return Lists.newArrayList(
return Arrays.asList(
PropertyStates.createProperty("timestamp", entry.getTimestamp(), Type.LONG),
PropertyStates.createProperty("revision", entry.getRevision())
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

import static org.apache.jackrabbit.oak.commons.conditions.Validate.checkArgument;
import static java.util.Objects.requireNonNull;
import static org.apache.jackrabbit.guava.common.collect.Lists.newArrayList;


import static java.util.Collections.emptySet;

Expand Down Expand Up @@ -49,6 +47,7 @@

import org.apache.jackrabbit.oak.api.IllegalRepositoryStateException;
import org.apache.jackrabbit.oak.commons.Buffer;
import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.commons.conditions.Validate;
import org.apache.jackrabbit.oak.segment.file.FileReaper;
import org.apache.jackrabbit.oak.segment.spi.monitor.FileStoreMonitor;
Expand Down Expand Up @@ -497,7 +496,7 @@ public String toString() {
lock.readLock().unlock();
}

return String.format("TarFiles{readers=%s,writer=%s}", newArrayList(iterable(head)), w);
return String.format("TarFiles{readers=%s,writer=%s}", CollectionUtils.toList(iterable(head)), w);
}

public long size() {
Expand Down
Loading
Loading