This is an automated email from the ASF dual-hosted git repository. reschke pushed a commit to branch OAK-11654 in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit 0a51f71a0cad16857bed440a502d64963b9458dd Author: Julian Reschke <[email protected]> AuthorDate: Fri Apr 11 08:14:17 2025 +0100 OAK-11654: Remove usage of Guava Suppliers.ofInstance --- .../lucene/property/PropertyIndexUpdateCallback.java | 6 ++---- .../apache/jackrabbit/oak/segment/SegmentNodeState.java | 5 ++--- .../jackrabbit/oak/segment/CancelableDiffTest.java | 3 +-- .../oak/plugins/document/DocumentNodeStore.java | 16 +++++++--------- .../oak/plugins/document/DocumentNodeStoreBuilder.java | 9 ++++----- 5 files changed, 16 insertions(+), 23 deletions(-) diff --git a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/PropertyIndexUpdateCallback.java b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/PropertyIndexUpdateCallback.java index 376444fc48..5651101cc5 100644 --- a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/PropertyIndexUpdateCallback.java +++ b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/PropertyIndexUpdateCallback.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene.property; import java.util.HashSet; @@ -41,7 +40,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static java.util.Objects.requireNonNull; -import static org.apache.jackrabbit.guava.common.base.Suppliers.ofInstance; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_CONTENT_NODE_NAME; import static org.apache.jackrabbit.oak.plugins.index.lucene.property.HybridPropertyIndexUtil.PROPERTY_INDEX; import static org.apache.jackrabbit.oak.plugins.index.lucene.property.HybridPropertyIndexUtil.PROP_CREATED; @@ -93,7 +91,7 @@ public class PropertyIndexUpdateCallback implements PropertyUpdateCallback { if (pd.unique) { UniqueEntryStoreStrategy s = new UniqueEntryStoreStrategy(INDEX_CONTENT_NODE_NAME, (nb) -> nb.setProperty(PROP_CREATED, updateTime)); - s.update(ofInstance(indexNode), + s.update(() -> indexNode, nodePath, null, null, @@ -102,7 +100,7 @@ public class PropertyIndexUpdateCallback implements PropertyUpdateCallback { uniquenessConstraintValidator.add(propertyRelativePath, afterKeys); } else { ContentMirrorStoreStrategy s = new ContentMirrorStoreStrategy(); - s.update(ofInstance(indexNode), + s.update(() -> indexNode, nodePath, null, null, diff --git a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeState.java b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeState.java index f3f90ab456..c546b16f13 100644 --- a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeState.java +++ b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeState.java @@ -41,7 +41,6 @@ import java.util.List; import java.util.UUID; import java.util.function.Supplier; -import org.apache.jackrabbit.guava.common.base.Suppliers; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.Buffer; @@ -97,7 +96,7 @@ public class SegmentNodeState extends Record implements NodeState { @Nullable BlobStore blobStore, @NotNull RecordId id ) { - this(reader, Suppliers.ofInstance(writer), blobStore, id, NoopStats.INSTANCE); + this(reader, () -> writer, blobStore, id, NoopStats.INSTANCE); } public SegmentNodeState( @@ -107,7 +106,7 @@ public class SegmentNodeState extends Record implements NodeState { @NotNull RecordId id, MeterStats readStats ) { - this(reader, Suppliers.ofInstance(writer), blobStore, id, readStats); + this(reader, () -> writer, blobStore, id, readStats); } RecordId getTemplateId() { diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/CancelableDiffTest.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/CancelableDiffTest.java index e574bbcc8a..4f6cd473d3 100644 --- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/CancelableDiffTest.java +++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/CancelableDiffTest.java @@ -18,7 +18,6 @@ */ package org.apache.jackrabbit.oak.segment; -import org.apache.jackrabbit.guava.common.base.Suppliers; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.apache.jackrabbit.oak.spi.state.NodeStateDiff; @@ -100,7 +99,7 @@ public class CancelableDiffTest { } private NodeStateDiff newCancelableDiff(NodeStateDiff wrapped, boolean cancel) { - return new CancelableDiff(wrapped, Suppliers.ofInstance(cancel)); + return new CancelableDiff(wrapped, () -> cancel); } } diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java index 0f7109ada8..c5f7c719d9 100644 --- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java +++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java @@ -135,8 +135,6 @@ import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.apache.jackrabbit.guava.common.base.Suppliers; - /** * Implementation of a NodeStore on {@link DocumentStore}. */ @@ -3803,11 +3801,11 @@ public final class DocumentNodeStore } private static Supplier<Integer> getDelay(DocumentNodeStore ns) { - int delay = 0; if (ns.getAsyncDelay() != 0) { - delay = (int) SECONDS.toMillis(MODIFIED_IN_SECS_RESOLUTION); + return () -> (int) SECONDS.toMillis(MODIFIED_IN_SECS_RESOLUTION); + } { + return () -> 0; } - return Suppliers.ofInstance(delay); } } @@ -3818,7 +3816,7 @@ public final class DocumentNodeStore BackgroundPurgeOperation(DocumentNodeStore nodeStore, AtomicBoolean isDisposed) { // run every 60 secs - super(nodeStore, isDisposed, Suppliers.ofInstance(60000)); + super(nodeStore, isDisposed, () -> 60000); } @Override @@ -3855,7 +3853,7 @@ public final class DocumentNodeStore // the sweep2 is fine to run every 60sec by default as it is not time critical // to achieve this we're doing a Math.min(60sec, 60 * getAsyncDelay()) super(nodeStore, isDisposed, - Suppliers.ofInstance(Math.min(60000, 60 * nodeStore.getAsyncDelay()))); + () -> Math.min(60000, 60 * nodeStore.getAsyncDelay())); if (sweep2Lock < 0) { throw new IllegalArgumentException("sweep2Lock must not be negative"); } @@ -3897,7 +3895,7 @@ public final class DocumentNodeStore BackgroundLeaseUpdate(DocumentNodeStore nodeStore, AtomicBoolean isDisposed) { - super(nodeStore, isDisposed, Suppliers.ofInstance(INTERVAL_MS)); + super(nodeStore, isDisposed, () -> INTERVAL_MS); } @Override @@ -3928,7 +3926,7 @@ public final class DocumentNodeStore BackgroundClusterUpdate(DocumentNodeStore nodeStore, AtomicBoolean isDisposed) { - super(nodeStore, isDisposed, Suppliers.ofInstance(1000)); + super(nodeStore, isDisposed, () -> 1000); } @Override diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBuilder.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBuilder.java index 702cdca0bc..5fb048e975 100644 --- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBuilder.java +++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBuilder.java @@ -20,7 +20,6 @@ import static java.util.Objects.isNull; import static java.util.Objects.requireNonNull; import static java.util.stream.Collectors.toUnmodifiableSet; import static org.apache.jackrabbit.oak.commons.conditions.Validate.checkArgument; -import static org.apache.jackrabbit.guava.common.base.Suppliers.ofInstance; import static org.apache.jackrabbit.oak.plugins.document.CommitQueue.DEFAULT_SUSPEND_TIMEOUT; import static org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService.DEFAULT_JOURNAL_GC_MAX_AGE_MILLIS; import static org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService.DEFAULT_VER_GC_MAX_AGE; @@ -117,7 +116,7 @@ public class DocumentNodeStoreBuilder<T extends DocumentNodeStoreBuilder<T>> { */ static final int UPDATE_LIMIT = Integer.getInteger("update.limit", DEFAULT_UPDATE_LIMIT); - protected Supplier<DocumentStore> documentStoreSupplier = ofInstance(new MemoryDocumentStore()); + protected Supplier<DocumentStore> documentStoreSupplier = () -> new MemoryDocumentStore(); protected Supplier<BlobStore> blobStoreSupplier; private DiffCache diffCache; private int clusterId = Integer.getInteger("oak.documentMK.clusterId", 0); @@ -512,7 +511,7 @@ public class DocumentNodeStoreBuilder<T extends DocumentNodeStoreBuilder<T>> { * @return this */ public T setDocumentStore(DocumentStore documentStore) { - this.documentStoreSupplier = ofInstance(documentStore); + this.documentStoreSupplier = () -> documentStore; return thisBuilder(); } @@ -534,13 +533,13 @@ public class DocumentNodeStoreBuilder<T extends DocumentNodeStoreBuilder<T>> { * @return this */ public T setBlobStore(BlobStore blobStore) { - this.blobStoreSupplier = ofInstance(blobStore); + this.blobStoreSupplier = () -> blobStore; return thisBuilder(); } public BlobStore getBlobStore() { if (blobStoreSupplier == null) { - blobStoreSupplier = ofInstance(new MemoryBlobStore()); + blobStoreSupplier = () -> new MemoryBlobStore(); } BlobStore blobStore = blobStoreSupplier.get(); configureBlobStore(blobStore);
