You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by da...@apache.org on 2024/12/21 14:12:05 UTC
(jackrabbit-oak) 01/01: OAK-11321 : renoved usage of guava Sets.union
This is an automated email from the ASF dual-hosted git repository.
daim pushed a commit to branch OAK-11321
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit 0116e9ea57dad0cf2e8ace34423219febf5c42fa
Author: Rishabh Kumar <di...@adobe.com>
AuthorDate: Sat Dec 21 19:41:30 2024 +0530
OAK-11321 : renoved usage of guava Sets.union
---
.../oak/plugins/blob/BlobGCCheckpointRefTest.java | 3 +-
.../jackrabbit/oak/plugins/blob/BlobGCTest.java | 26 ++++-------
.../oak/commons/collections/CollectionUtils.java | 17 ++++++++
.../oak/commons/collections/package-info.java | 2 +-
.../jackrabbit/oak/commons/FileIOUtilsTest.java | 10 ++---
.../commons/collections/CollectionUtilsTest.java | 51 ++++++++++++++++++++++
.../oak/plugins/commit/MergingNodeStateDiff.java | 7 ++-
.../oak/plugins/nodetype/TypeRegistration.java | 3 +-
.../jackrabbit/oak/query/ast/CoalesceImpl.java | 4 +-
.../composite/CompositeProviderCustomMixTest.java | 8 ++--
.../blob/datastore/DataStoreTrackerGCTest.java | 12 ++---
.../jackrabbit/oak/run/DataStoreCheckTest.java | 10 ++---
.../oak/composite/InitialContentMigrator.java | 6 ++-
.../oak/plugins/document/rdb/RDBDocumentStore.java | 2 +-
.../oak/plugins/document/CommitQueueTest.java | 4 +-
.../plugins/document/SharedBlobStoreGCTest.java | 7 ++-
.../oak/upgrade/RepositorySidegrade.java | 5 ++-
.../jackrabbit/oak/upgrade/RepositoryUpgrade.java | 8 ++--
18 files changed, 118 insertions(+), 67 deletions(-)
diff --git a/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/BlobGCCheckpointRefTest.java b/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/BlobGCCheckpointRefTest.java
index 8ceaa979b2..e0f922771d 100644
--- a/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/BlobGCCheckpointRefTest.java
+++ b/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/BlobGCCheckpointRefTest.java
@@ -27,6 +27,7 @@ import javax.management.openmbean.TabularData;
import org.apache.jackrabbit.guava.common.collect.Sets;
import org.apache.jackrabbit.oak.api.jmx.CheckpointMBean;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
import org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils;
import org.apache.jackrabbit.oak.stats.Clock;
@@ -59,7 +60,7 @@ public class BlobGCCheckpointRefTest extends BlobGCTest {
checkpointMBean.createCheckpoint(100);
Set<String> afterCheckpointBlobs = createBlobs(cluster.blobStore, 2, 100);
- Set<String> present = Sets.union(cluster.blobStoreState.blobsPresent, afterCheckpointBlobs);
+ Set<String> present = CollectionUtils.union(cluster.blobStoreState.blobsPresent, afterCheckpointBlobs);
long maxGcAge = checkpointMBean.getOldestCheckpointCreationTimestamp() - afterSetupTime;
log.info("{} blobs remaining : {}", present.size(), present);
diff --git a/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/BlobGCTest.java b/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/BlobGCTest.java
index 03f71af359..9b2e89767f 100644
--- a/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/BlobGCTest.java
+++ b/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/BlobGCTest.java
@@ -52,7 +52,6 @@ import java.util.concurrent.atomic.AtomicReference;
import ch.qos.logback.classic.Level;
import org.apache.jackrabbit.guava.common.collect.Iterators;
-import org.apache.jackrabbit.guava.common.collect.Lists;
import org.apache.jackrabbit.guava.common.collect.Sets;
import org.apache.jackrabbit.guava.common.io.Closer;
import org.apache.jackrabbit.oak.api.Blob;
@@ -61,6 +60,7 @@ import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.api.blob.BlobAccessProvider;
import org.apache.jackrabbit.oak.api.blob.BlobUpload;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser;
import org.apache.jackrabbit.oak.commons.junit.LogCustomizer;
import org.apache.jackrabbit.oak.plugins.blob.MarkSweepGarbageCollector.NotAllRepositoryMarkedException;
@@ -214,10 +214,8 @@ public class BlobGCTest {
Cluster secondCluster = new Cluster(folder.newFolder(), cluster.blobStore, secondClusterNodeStore, 100);
closer.register(secondCluster);
- Sets.SetView<String> totalPresent =
- Sets.union(cluster.blobStoreState.blobsPresent, secondCluster.blobStoreState.blobsPresent);
- Sets.SetView<String> totalAdded =
- Sets.union(cluster.blobStoreState.blobsAdded, secondCluster.blobStoreState.blobsAdded);
+ Set<String> totalPresent = CollectionUtils.union(cluster.blobStoreState.blobsPresent, secondCluster.blobStoreState.blobsPresent);
+ Set<String> totalAdded = CollectionUtils.union(cluster.blobStoreState.blobsAdded, secondCluster.blobStoreState.blobsAdded);
// Execute mark on the default cluster
executeGarbageCollection(cluster, cluster.getCollector(0), true);
@@ -238,8 +236,7 @@ public class BlobGCTest {
Cluster secondCluster = new Cluster(folder.newFolder(), cluster.blobStore, secondClusterNodeStore, 100);
closer.register(secondCluster);
- Sets.SetView<String> totalAdded =
- Sets.union(cluster.blobStoreState.blobsAdded, secondCluster.blobStoreState.blobsAdded);
+ Set<String> totalAdded = CollectionUtils.union(cluster.blobStoreState.blobsAdded, secondCluster.blobStoreState.blobsAdded);
Set<String> existingAfterGC = executeGarbageCollection(secondCluster, secondCluster.getCollector(0), false);
@@ -260,8 +257,7 @@ public class BlobGCTest {
((SharedDataStore) secondCluster.blobStore).deleteMetadataRecord(REPOSITORY.getNameFromId(secondCluster.repoId));
secondCluster.setRepoId(cluster.repoId);
- Sets.SetView<String> totalPresent =
- Sets.union(cluster.blobStoreState.blobsPresent, secondCluster.blobStoreState.blobsPresent);
+ Set<String> totalPresent = CollectionUtils.union(cluster.blobStoreState.blobsPresent, secondCluster.blobStoreState.blobsPresent);
// Execute mark on the default cluster
executeGarbageCollection(cluster, cluster.getCollector(0), true);
@@ -279,10 +275,8 @@ public class BlobGCTest {
Cluster secondCluster = new Cluster(folder.newFolder(), cluster.blobStore, secondClusterNodeStore, 100);
closer.register(secondCluster);
- Sets.SetView<String> totalPresent =
- Sets.union(cluster.blobStoreState.blobsPresent, secondCluster.blobStoreState.blobsPresent);
- Sets.SetView<String> totalAdded =
- Sets.union(cluster.blobStoreState.blobsAdded, secondCluster.blobStoreState.blobsAdded);
+ Set<String> totalPresent = CollectionUtils.union(cluster.blobStoreState.blobsPresent, secondCluster.blobStoreState.blobsPresent);
+ Set<String> totalAdded = CollectionUtils.union(cluster.blobStoreState.blobsAdded, secondCluster.blobStoreState.blobsAdded);
clock.waitUntil(clock.getTime() + 5);
@@ -309,10 +303,8 @@ public class BlobGCTest {
Cluster secondCluster = new Cluster(folder.newFolder(), cluster.blobStore, secondClusterNodeStore, 100);
closer.register(secondCluster);
- Sets.SetView<String> totalPresent =
- Sets.union(cluster.blobStoreState.blobsPresent, secondCluster.blobStoreState.blobsPresent);
- Sets.SetView<String> totalAdded =
- Sets.union(cluster.blobStoreState.blobsAdded, secondCluster.blobStoreState.blobsAdded);
+ Set<String> totalPresent = CollectionUtils.union(cluster.blobStoreState.blobsPresent, secondCluster.blobStoreState.blobsPresent);
+ Set<String> totalAdded = CollectionUtils.union(cluster.blobStoreState.blobsAdded, secondCluster.blobStoreState.blobsAdded);
// Execute mark on the default cluster
executeGarbageCollection(cluster, cluster.getCollector(5), true);
diff --git a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtils.java b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtils.java
index 14e4833730..323ee6be8d 100644
--- a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtils.java
+++ b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtils.java
@@ -206,6 +206,23 @@ public class CollectionUtils {
return result;
}
+ /**
+ * Returns a new set containing the union of the two specified sets.
+ * The union of two sets is a set containing all the elements of both sets.
+ *
+ * @param <T> the type of elements in the sets
+ * @param s1 the first set, must not be null
+ * @param s2 the second set, must not be null
+ * @return a new set containing the union of the two specified sets
+ * @throws NullPointerException if either of the sets is null
+ */
+ @NotNull
+ public static <T> Set<T> union(@NotNull final Set<T> s1, @NotNull final Set<T> s2) {
+ Objects.requireNonNull(s1);
+ Objects.requireNonNull(s2);
+ return Stream.concat(s1.stream(), s2.stream()).collect(Collectors.toSet());
+ }
+
/**
* Convert an iterable to a {@link java.util.ArrayDeque}.
* The returning array deque is mutable and supports all optional operations.
diff --git a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/package-info.java b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/package-info.java
index df06d85d18..dec44b05ff 100644
--- a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/package-info.java
+++ b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/package-info.java
@@ -21,7 +21,7 @@
* Utilities for Java collections and streams.
*/
@Internal(since = "1.0.0")
-@Version("1.3.0")
+@Version("1.4.0")
package org.apache.jackrabbit.oak.commons.collections;
import org.apache.jackrabbit.oak.commons.annotations.Internal;
import org.osgi.annotation.versioning.Version;
diff --git a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/FileIOUtilsTest.java b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/FileIOUtilsTest.java
index 275602a01d..9094c55a17 100644
--- a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/FileIOUtilsTest.java
+++ b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/FileIOUtilsTest.java
@@ -19,7 +19,6 @@
package org.apache.jackrabbit.oak.commons;
import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.apache.jackrabbit.guava.common.collect.Sets.union;
import static org.apache.jackrabbit.oak.commons.FileIOUtils.append;
import static org.apache.jackrabbit.oak.commons.FileIOUtils.copy;
import static org.apache.jackrabbit.oak.commons.FileIOUtils.lexComparator;
@@ -61,7 +60,6 @@ import java.util.Set;
import org.apache.commons.io.FileUtils;
import org.apache.jackrabbit.guava.common.base.Splitter;
-import org.apache.jackrabbit.guava.common.collect.Iterators;
import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.commons.sort.EscapeUtils;
import org.jetbrains.annotations.Nullable;
@@ -238,7 +236,7 @@ public class FileIOUtilsTest {
File f3 = assertWrite(added3.iterator(), false, added3.size());
append(List.of(f2, f3), f1, true);
- assertEquals(union(union(added1, added2), added3),
+ assertEquals(CollectionUtils.union(CollectionUtils.union(added1, added2), added3),
readStringsAsSet(new FileInputStream(f1), false));
assertTrue(!f2.exists());
assertTrue(!f3.exists());
@@ -258,7 +256,7 @@ public class FileIOUtilsTest {
append(List.of(f2, f3), f1, false);
- assertEquals(union(union(added1, added2), added3),
+ assertEquals(CollectionUtils.union(CollectionUtils.union(added1, added2), added3),
readStringsAsSet(new FileInputStream(f1), false));
assertTrue(f2.exists());
assertTrue(f3.exists());
@@ -294,7 +292,7 @@ public class FileIOUtilsTest {
append(List.of(f2), f1, true);
- assertEquals(union(added1, added2),
+ assertEquals(CollectionUtils.union(added1, added2),
readStringsAsSet(new FileInputStream(f1), true));
}
@@ -308,7 +306,7 @@ public class FileIOUtilsTest {
append(List.of(f1), f2, true);
- assertEquals(union(added1, added2), readStringsAsSet(new FileInputStream(f2), true));
+ assertEquals(CollectionUtils.union(added1, added2), readStringsAsSet(new FileInputStream(f2), true));
}
@Test
diff --git a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtilsTest.java b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtilsTest.java
index d03467948e..9508e4e432 100644
--- a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtilsTest.java
+++ b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtilsTest.java
@@ -206,6 +206,57 @@ public class CollectionUtilsTest {
CollectionUtils.toLinkedSet((String[])null);
}
+ @Test
+ public void testUnionWithNonEmptySets() {
+ final Set<String> set1 = Set.of("a", "b", "c");
+ final Set<String> set2 = Set.of("d", "e", "f");
+
+ final Set<String> expected = Set.of("a", "b", "c", "d", "e", "f");
+ Assert.assertEquals(expected, CollectionUtils.union(set1, set2));
+ }
+
+ @Test
+ public void testUnionWithEmptySet() {
+ final Set<String> set1 = Set.of("a", "b", "c");
+ final Set<String> set2 = new HashSet<>();
+
+ final Set<String> expected = Set.of("a", "b", "c");
+ Assert.assertEquals(expected, CollectionUtils.union(set1, set2));
+ }
+
+ @Test
+ public void testUnionWithBothEmptySets() {
+ final Set<String> set1 = new HashSet<>();
+ final Set<String> set2 = new HashSet<>();
+
+ Assert.assertEquals(new HashSet<>(), CollectionUtils.union(set1, set2));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testUnionWithNullFirstSet() {
+ Set<String> set1 = null;
+ Set<String> set2 = Set.of("a", "b", "c");
+
+ CollectionUtils.union(set1, set2);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testUnionWithNullSecondSet() {
+ Set<String> set1 = Set.of("a", "b", "c");
+ Set<String> set2 = null;
+
+ CollectionUtils.union(set1, set2);
+ }
+
+ @Test
+ public void testUnionWithOverlappingSets() {
+ final Set<String> set1 = Set.of("a", "b", "c");
+ final Set<String> set2 = Set.of("b", "c", "d");
+
+ final Set<String> expected = Set.of("a", "b", "c", "d");
+ Assert.assertEquals(expected, CollectionUtils.union(set1, set2));
+ }
+
@Test
public void iteratorToIIteratable() {
Iterator<String> iterator = List.of("a", "b", "c").iterator();
diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java
index 5cc80dc50a..7dde9ab9d1 100644
--- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java
+++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java
@@ -34,9 +34,8 @@ import static org.apache.jackrabbit.oak.spi.state.ConflictType.DELETE_DELETED_PR
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import java.util.stream.StreamSupport;
+import java.util.stream.Stream;
-import org.apache.jackrabbit.guava.common.collect.Sets;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.json.JsopDiff;
@@ -135,8 +134,8 @@ public final class MergingNodeStateDiff extends DefaultNodeStateDiff {
NodeState oursNS = conflictInfo.getChildNode(OURS);
NodeState baseNS = conflictInfo.getChildNode(BASE);
- Set<String> candidates = Sets.union(CollectionUtils.toSet(oursNS.getChildNodeNames()),
- CollectionUtils.toSet(baseNS.getChildNodeNames()));
+ Set<String> candidates = Stream.concat(CollectionUtils.toStream(oursNS.getChildNodeNames()),
+ CollectionUtils.toStream(baseNS.getChildNodeNames())).collect(toSet());
for (String name : candidates) {
NodeState ours = oursNS.getChildNode(name);
NodeState base = baseNS.getChildNode(name);
diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeRegistration.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeRegistration.java
index d1b65f5f37..ea3566c956 100644
--- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeRegistration.java
+++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeRegistration.java
@@ -19,7 +19,6 @@ package org.apache.jackrabbit.oak.plugins.nodetype;
import static org.apache.jackrabbit.guava.common.collect.Iterables.addAll;
import static org.apache.jackrabbit.guava.common.collect.Iterables.contains;
import static org.apache.jackrabbit.guava.common.collect.Iterables.isEmpty;
-import static org.apache.jackrabbit.guava.common.collect.Sets.union;
import static java.util.Collections.emptyList;
import static org.apache.jackrabbit.JcrConstants.JCR_CHILDNODEDEFINITION;
import static org.apache.jackrabbit.JcrConstants.JCR_ISMIXIN;
@@ -124,7 +123,7 @@ class TypeRegistration extends DefaultNodeStateDiff {
*/
Set<String> getModifiedTypes(NodeState beforeTypes) {
Set<String> types = new HashSet<>();
- for (String name : union(changedTypes, removedTypes)) {
+ for (String name : CollectionUtils.union(changedTypes, removedTypes)) {
types.add(name);
NodeState type = beforeTypes.getChildNode(name);
addAll(types, type.getNames(REP_PRIMARY_SUBTYPES));
diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/CoalesceImpl.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/CoalesceImpl.java
index 9465c34338..37df8c0fca 100644
--- a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/CoalesceImpl.java
+++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/CoalesceImpl.java
@@ -18,9 +18,9 @@
*/
package org.apache.jackrabbit.oak.query.ast;
-import org.apache.jackrabbit.guava.common.collect.Sets;
import org.apache.jackrabbit.oak.api.PropertyValue;
import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.query.index.FilterImpl;
import org.apache.jackrabbit.oak.spi.query.QueryConstants;
import org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry;
@@ -68,7 +68,7 @@ public class CoalesceImpl extends DynamicOperandImpl {
@Override
public Set<SelectorImpl> getSelectors() {
- return Sets.union(
+ return CollectionUtils.union(
operand1.getSelectors(),
operand2.getSelectors()
);
diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderCustomMixTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderCustomMixTest.java
index 1121e41e61..6407a51677 100644
--- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderCustomMixTest.java
+++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderCustomMixTest.java
@@ -59,7 +59,7 @@ public class CompositeProviderCustomMixTest extends AbstractSecurityTest {
public void hasPrivilegesTest() throws Exception {
Set<String> supp1 = Set.of(JCR_READ, JCR_NAMESPACE_MANAGEMENT);
Set<String> supp2 = Set.of(JCR_READ, JCR_WRITE);
- Set<String> all = Sets.union(supp1, supp2);
+ Set<String> all = CollectionUtils.union(supp1, supp2);
// tests all possible 256 shuffles
for (CompositionType type : CompositionType.values()) {
@@ -84,7 +84,7 @@ public class CompositeProviderCustomMixTest extends AbstractSecurityTest {
public void isGrantedTest() throws Exception {
Set<String> supp1 = Set.of(JCR_READ, JCR_NODE_TYPE_MANAGEMENT);
Set<String> supp2 = Set.of(JCR_READ, JCR_WRITE);
- Set<String> all = Sets.union(supp1, supp2);
+ Set<String> all = CollectionUtils.union(supp1, supp2);
Map<String, Long> grantMap = new HashMap<>();
grantMap.put(JCR_READ, Permissions.READ);
@@ -131,7 +131,7 @@ public class CompositeProviderCustomMixTest extends AbstractSecurityTest {
public void getRepositoryPermissionTest() throws Exception {
Set<String> supp1 = Set.of(JCR_READ, JCR_NODE_TYPE_MANAGEMENT);
Set<String> supp2 = Set.of(JCR_READ, JCR_WRITE);
- Set<String> all = Sets.union(supp1, supp2);
+ Set<String> all = CollectionUtils.union(supp1, supp2);
Map<String, Long> grantMap = new HashMap<>();
grantMap.put(JCR_READ, Permissions.READ);
@@ -161,7 +161,7 @@ public class CompositeProviderCustomMixTest extends AbstractSecurityTest {
public void getTreePermissionTest() throws Exception {
Set<String> supp1 = Set.of(JCR_READ, JCR_NODE_TYPE_MANAGEMENT);
Set<String> supp2 = Set.of(JCR_READ, JCR_WRITE);
- Set<String> all = Sets.union(supp1, supp2);
+ Set<String> all = CollectionUtils.union(supp1, supp2);
Map<String, Long> grantMap = new HashMap<>();
grantMap.put(JCR_READ, Permissions.READ);
diff --git a/oak-it/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreTrackerGCTest.java b/oak-it/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreTrackerGCTest.java
index 3f66fed90b..30b83bcb02 100644
--- a/oak-it/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreTrackerGCTest.java
+++ b/oak-it/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreTrackerGCTest.java
@@ -31,7 +31,6 @@ import java.util.Set;
import java.util.concurrent.ScheduledFuture;
import ch.qos.logback.classic.Level;
-import org.apache.jackrabbit.guava.common.collect.Lists;
import org.apache.jackrabbit.guava.common.collect.Sets;
import org.apache.commons.io.FileUtils;
import org.apache.jackrabbit.oak.api.Blob;
@@ -62,7 +61,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-import static org.apache.jackrabbit.guava.common.collect.Sets.union;
import static java.lang.String.valueOf;
import static java.util.concurrent.Executors.newSingleThreadExecutor;
import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
@@ -470,12 +468,9 @@ public class DataStoreTrackerGCTest {
Set<String> existingAfterGC = iterate(s1);
// Check the state of the blob store after gc
- assertEquals(
- union(state1.blobsPresent, state2.blobsPresent), existingAfterGC);
+ assertEquals(CollectionUtils.union(state1.blobsPresent, state2.blobsPresent), existingAfterGC);
// Tracked blobs should reflect deletions after gc
- assertEquals(
- union(state1.blobsPresent, state2.blobsPresent),
- retrieveTracked(tracker1));
+ assertEquals(CollectionUtils.union(state1.blobsPresent, state2.blobsPresent), retrieveTracked(tracker1));
// Again create snapshots at both cluster nodes to synchronize the latest state of
// local references with datastore at each node
@@ -506,8 +501,7 @@ public class DataStoreTrackerGCTest {
customLogs.finished();
// Check the state of the blob store after gc
- assertEquals(
- union(state1.blobsPresent, state2.blobsPresent), existingAfterGC);
+ assertEquals(CollectionUtils.union(state1.blobsPresent, state2.blobsPresent), existingAfterGC);
}
/**
diff --git a/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCheckTest.java b/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCheckTest.java
index 3512ff16ec..dd4d8d5b90 100644
--- a/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCheckTest.java
+++ b/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCheckTest.java
@@ -43,8 +43,6 @@ import java.util.Set;
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.guava.common.collect.Maps;
-import org.apache.jackrabbit.guava.common.collect.Sets;
import joptsimple.internal.Strings;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.FileFilterUtils;
@@ -210,7 +208,7 @@ public class DataStoreCheckTest {
testAllParams(dump, repoHome);
assertFileEquals(dump, "[id]", blobsAdded);
- assertFileEquals(dump, "[ref]", Sets.union(blobsAdded, Set.of(deletedBlobId)));
+ assertFileEquals(dump, "[ref]", CollectionUtils.union(blobsAdded, Set.of(deletedBlobId)));
assertFileEquals(dump, "[consistency]", Set.of(deletedBlobId));
}
@@ -233,7 +231,7 @@ public class DataStoreCheckTest {
assertFileEquals(dump, "[id]", encodedIds(blobsAdded, dsOption));
assertFileEquals(dump, "[ref]",
- encodedIdsAndPath(Sets.union(blobsAdded, Set.of(deletedBlobId)), dsOption, blobsAddedWithNodes));
+ encodedIdsAndPath(CollectionUtils.union(blobsAdded, Set.of(deletedBlobId)), dsOption, blobsAddedWithNodes));
assertFileEquals(dump, "[consistency]",
encodedIdsAndPath(Set.of(deletedBlobId), dsOption, blobsAddedWithNodes));
}
@@ -265,7 +263,7 @@ public class DataStoreCheckTest {
testAllParams(dump, repoHome);
assertFileEquals(dump, "[id]", blobsAdded);
- assertFileEquals(dump, "[ref]", Sets.union(blobsAdded, Set.of(deletedBlobId, activeDeletedBlobId)));
+ assertFileEquals(dump, "[ref]", CollectionUtils.union(blobsAdded, Set.of(deletedBlobId, activeDeletedBlobId)));
assertFileEquals(dump, "[consistency]", Set.of(deletedBlobId));
}
@@ -297,7 +295,7 @@ public class DataStoreCheckTest {
assertFileEquals(dump, "[id]", encodedIds(blobsAdded, dsOption));
assertFileEquals(dump, "[ref]",
- encodedIdsAndPath(Sets.union(blobsAdded, Set.of(deletedBlobId, activeDeletedBlobId)), dsOption,
+ encodedIdsAndPath(CollectionUtils.union(blobsAdded, Set.of(deletedBlobId, activeDeletedBlobId)), dsOption,
blobsAddedWithNodes));
assertFileEquals(dump, "[consistency]",
encodedIdsAndPath(Set.of(deletedBlobId), dsOption, blobsAddedWithNodes));
diff --git a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/InitialContentMigrator.java b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/InitialContentMigrator.java
index 6d6155819e..9ea1bc75fd 100644
--- a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/InitialContentMigrator.java
+++ b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/InitialContentMigrator.java
@@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.oak.composite;
-import org.apache.jackrabbit.guava.common.collect.Sets;
import org.apache.jackrabbit.oak.api.CommitFailedException;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.Type;
@@ -43,6 +42,8 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import static org.apache.jackrabbit.oak.spi.cluster.ClusterRepositoryInfo.CLUSTER_CONFIG_NODE;
@@ -82,7 +83,8 @@ public class InitialContentMigrator {
this.excludeFragments = Set.of(seedMount.getPathFragmentName());
if (seedMount instanceof MountInfo) {
- this.excludePaths = Sets.union(((MountInfo) seedMount).getIncludedPaths(), DEFAULT_IGNORED_PATHS);
+ this.excludePaths = Stream.concat(((MountInfo) seedMount).getIncludedPaths().stream(), DEFAULT_IGNORED_PATHS.stream())
+ .collect(Collectors.toUnmodifiableSet());
this.fragmentPaths = new HashSet<>();
for (String p : ((MountInfo) seedMount).getPathsSupportingFragments()) {
fragmentPaths.add(stripPatternCharacters(p));
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
index f53b05b86b..186295ad51 100755
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
@@ -532,7 +532,7 @@ public class RDBDocumentStore implements DocumentStore {
}
oldDocs.putAll(freshDocs);
- try (CacheChangesTracker tracker = obtainTracker(collection, Sets.union(oldDocs.keySet(), missingDocs) )) {
+ try (CacheChangesTracker tracker = obtainTracker(collection, CollectionUtils.union(oldDocs.keySet(), missingDocs) )) {
List<T> docsToUpdate = new ArrayList<T>(updates.size());
Set<String> keysToUpdate = new HashSet<String>();
for (UpdateOp update : updates) {
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitQueueTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitQueueTest.java
index 3fc45f2b93..fefae7a761 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitQueueTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/CommitQueueTest.java
@@ -28,6 +28,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
import org.apache.jackrabbit.oak.spi.commit.Observer;
@@ -40,7 +41,6 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.jackrabbit.guava.common.collect.Sets.union;
import static java.util.Collections.synchronizedList;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -229,7 +229,7 @@ public class CommitQueueTest {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
- queue.suspendUntilAll(union(Set.of(newHeadRev), revisions));
+ queue.suspendUntilAll(CollectionUtils.union(Set.of(newHeadRev), revisions));
}
});
t.start();
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/SharedBlobStoreGCTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/SharedBlobStoreGCTest.java
index 0c8542556f..4fe695ef11 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/SharedBlobStoreGCTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/SharedBlobStoreGCTest.java
@@ -29,7 +29,6 @@ import java.util.Random;
import java.util.Set;
import java.util.concurrent.TimeUnit;
-import org.apache.jackrabbit.guava.common.collect.Lists;
import org.apache.jackrabbit.guava.common.collect.Sets;
import org.apache.jackrabbit.guava.common.util.concurrent.MoreExecutors;
import org.apache.jackrabbit.core.data.DataStore;
@@ -128,7 +127,7 @@ public class SharedBlobStoreGCTest {
cluster1.gc.collectGarbage(false);
assertTrue(Sets.symmetricDifference(
- Sets.union(cluster1.getInitBlobs(), cluster2.getInitBlobs()),
+ CollectionUtils.union(cluster1.getInitBlobs(), cluster2.getInitBlobs()),
cluster1.getExistingBlobIds()).isEmpty());
}
@@ -145,7 +144,7 @@ public class SharedBlobStoreGCTest {
cluster1.gc.collectGarbage(false);
assertTrue(Sets.symmetricDifference(
- Sets.union(cluster1.getInitBlobs(), cluster2.getInitBlobs()),
+ CollectionUtils.union(cluster1.getInitBlobs(), cluster2.getInitBlobs()),
cluster1.getExistingBlobIds()).isEmpty());
}
@@ -211,7 +210,7 @@ public class SharedBlobStoreGCTest {
cluster2.gc.collectGarbage(false);
assertTrue(Sets.symmetricDifference(
- Sets.union(cluster1.getInitBlobs(), cluster2.getInitBlobs()),
+ CollectionUtils.union(cluster1.getInitBlobs(), cluster2.getInitBlobs()),
cluster1.getExistingBlobIds()).isEmpty());
}
diff --git a/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositorySidegrade.java b/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositorySidegrade.java
index 83e8c2c85f..3da4776046 100755
--- a/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositorySidegrade.java
+++ b/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositorySidegrade.java
@@ -24,6 +24,8 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import javax.jcr.RepositoryException;
@@ -69,7 +71,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.util.Objects.requireNonNull;
-import static org.apache.jackrabbit.guava.common.collect.Sets.union;
import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
import static org.apache.jackrabbit.JcrConstants.JCR_SYSTEM;
import static org.apache.jackrabbit.oak.plugins.migration.NodeStateCopier.copyProperties;
@@ -470,7 +471,7 @@ public class RepositorySidegrade {
}
excludes.add("/:async");
- final Set<String> merges = union(Set.copyOf(this.mergePaths), Set.of("/jcr:system"));
+ final Set<String> merges = Stream.concat(this.mergePaths.stream(), Stream.of("/jcr:system")).collect(Collectors.toUnmodifiableSet());
NodeStateCopier.builder()
.include(includes)
.exclude(Set.copyOf(excludes))
diff --git a/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java b/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
index cf579d980b..33548361f6 100644
--- a/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
+++ b/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
@@ -17,7 +17,6 @@
package org.apache.jackrabbit.oak.upgrade;
import static java.util.Objects.requireNonNull;
-import static org.apache.jackrabbit.guava.common.collect.Sets.union;
import static org.apache.jackrabbit.JcrConstants.JCR_SYSTEM;
import static org.apache.jackrabbit.oak.plugins.migration.FilteringNodeState.ALL;
import static org.apache.jackrabbit.oak.plugins.migration.FilteringNodeState.NONE;
@@ -42,6 +41,8 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import javax.jcr.NamespaceException;
import javax.jcr.Node;
@@ -57,7 +58,6 @@ import javax.jcr.security.Privilege;
import org.apache.jackrabbit.guava.common.base.Stopwatch;
import org.apache.jackrabbit.guava.common.collect.ImmutableList;
-
import org.apache.jackrabbit.guava.common.collect.Lists;
import org.apache.commons.collections4.bidimap.DualHashBidiMap;
import org.apache.jackrabbit.JcrConstants;
@@ -939,8 +939,8 @@ public class RepositoryUpgrade {
private String copyWorkspace(NodeState sourceRoot, NodeBuilder targetRoot, String workspaceName)
throws RepositoryException {
final Set<String> includes = calculateEffectiveIncludePaths(includePaths, sourceRoot);
- final Set<String> excludes = union(Set.copyOf(this.excludePaths), Set.of("/jcr:system/jcr:versionStorage"));
- final Set<String> merges = union(Set.copyOf(this.mergePaths), Set.of("/jcr:system"));
+ final Set<String> excludes = Stream.concat(this.excludePaths.stream(), Stream.of("/jcr:system/jcr:versionStorage")).collect(Collectors.toUnmodifiableSet());
+ final Set<String> merges = Stream.concat(this.mergePaths.stream(), Stream.of("/jcr:system")).collect(Collectors.toUnmodifiableSet());
logger.info("Copying workspace {} [i: {}, e: {}, m: {}]", workspaceName, includes, excludes, merges);