Skip to content

Commit

Permalink
OAK-11353 : removed usage of Guava's Maps.newHashMap
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishabh Kumar committed Jan 7, 2025
1 parent 5d04e22 commit 611e9b0
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@

import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;

import javax.jcr.query.Query;

import org.apache.jackrabbit.guava.common.collect.Maps;
import org.apache.jackrabbit.oak.Oak;
import org.apache.jackrabbit.oak.api.ContentRepository;
import org.apache.jackrabbit.oak.api.PropertyValue;
import org.apache.jackrabbit.oak.api.ResultRow;
import org.apache.jackrabbit.oak.api.Tree;
import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
Expand Down Expand Up @@ -186,7 +185,7 @@ public void unionSortQueries() throws Exception {

private String measureWithLimit(String query, String lang, int limit) throws ParseException {
List<? extends ResultRow> result = CollectionUtils.toList(
qe.executeQuery(query, lang, limit, 0, Maps.<String, PropertyValue>newHashMap(),
qe.executeQuery(query, lang, limit, 0, new HashMap<>(),
NO_MAPPINGS).getRows());

String measure = "";
Expand Down
2 changes: 1 addition & 1 deletion oak-examples/standalone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ default config files depending on options provided (like --mongo ) and then
construct the Oak Repository instance via `OakOSGiRepositoryFactory`

private Repository createRepository(List<String> repoConfigs, File repoHomeDir) throws RepositoryException {
Map<String,Object> config = Maps.newHashMap();
Map<String,Object> config = new HashMap<>();
config.put(OakOSGiRepositoryFactory.REPOSITORY_HOME, repoHomeDir.getAbsolutePath());
config.put(OakOSGiRepositoryFactory.REPOSITORY_CONFIG_FILE, commaSepFilePaths(repoConfigs));
config.put(OakOSGiRepositoryFactory.REPOSITORY_SHUTDOWN_ON_TIMEOUT, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static org.apache.jackrabbit.guava.common.collect.Iterables.toArray;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
Expand All @@ -32,8 +33,6 @@
import org.apache.jackrabbit.util.XMLChar;
import org.jetbrains.annotations.NotNull;

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

/**
* {@code SessionNamespaces} implements namespace handling on the JCR
* Session level. That is, it maintains a map of session local namespace
Expand All @@ -43,7 +42,7 @@
public class SessionNamespaces extends LocalNameMapper {

public SessionNamespaces(@NotNull Root root) {
super(root, Maps.<String, String>newHashMap());
super(root, new HashMap<>());
}

// The code below was initially copied from JCR Commons AbstractSession,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@

import org.apache.jackrabbit.guava.common.collect.ComparisonChain;
import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.guava.common.collect.Maps;
import org.apache.jackrabbit.guava.common.io.CountingInputStream;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
Expand Down Expand Up @@ -1430,7 +1429,7 @@ public void luceneAndExclude() throws Exception {

private String measureWithLimit(String query, String lang, int limit) throws ParseException {
List<? extends ResultRow> result = CollectionUtils.toList(
qe.executeQuery(query, lang, limit, 0, Maps.<String, PropertyValue>newHashMap(),
qe.executeQuery(query, lang, limit, 0, new HashMap<>(),
NO_MAPPINGS).getRows());

String measure = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import org.apache.felix.connect.launch.PojoServiceRegistry;
import org.apache.jackrabbit.guava.common.collect.Maps;
import org.apache.jackrabbit.oak.spi.state.NodeState;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
import org.junit.Assert;
Expand Down Expand Up @@ -155,7 +155,7 @@ public List<NodeStore> getStores() {
return result;
}

private final Map<ServiceReference<NodeStore>, NodeStore> stores = Maps.newHashMap();
private final Map<ServiceReference<NodeStore>, NodeStore> stores = new HashMap<>();
private final Object trackerLock = new Object();
private final CountDownLatch trackerLatch;
private final CountDownLatch deactivateLatch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.slf4j.LoggerFactory;

import org.apache.jackrabbit.guava.common.base.Suppliers;
import org.apache.jackrabbit.guava.common.collect.Maps;

import static java.util.Objects.requireNonNull;

Expand Down Expand Up @@ -110,7 +109,7 @@ private SplitOperations(@NotNull final NodeDocument doc,
this.headRevision = requireNonNull(headRev).getRevision(context.getClusterId());
this.numRevsThreshold = numRevsThreshold;
this.nodeExistsAtHeadRevision = Suppliers.memoize(() -> doc.getLiveRevision(context, headRev,
Maps.<Revision, String>newHashMap(),
new HashMap<>(),
new LastRevs(headRev)) != null);
}

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

import org.apache.jackrabbit.guava.common.collect.Maps;
import org.apache.jackrabbit.oak.plugins.document.Collection;
import org.apache.jackrabbit.oak.plugins.document.Document;
import org.apache.jackrabbit.oak.plugins.document.DocumentMKBuilderProvider;
Expand All @@ -37,6 +36,7 @@
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

import static org.junit.Assert.assertFalse;
Expand Down Expand Up @@ -102,7 +102,7 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl

uoeThrown = false;
try {
readOnlyStore.remove(collection, Maps.<String, Long>newHashMap());
readOnlyStore.remove(collection, new HashMap<>());
} catch (UnsupportedOperationException uoe) {
//catch uoe thrown by read only wrapper
uoeThrown = true;
Expand Down

0 comments on commit 611e9b0

Please sign in to comment.