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 st...@apache.org on 2024/11/06 20:31:14 UTC

(jackrabbit-oak) branch revert-1845-OAK-11248 created (now 2ba4dfaca5)

This is an automated email from the ASF dual-hosted git repository.

stefanegli pushed a change to branch revert-1845-OAK-11248
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git


      at 2ba4dfaca5 Revert "OAK-11248 : closing all features in one single loop"

This branch includes the following new commits:

     new 2ba4dfaca5 Revert "OAK-11248 : closing all features in one single loop"

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(jackrabbit-oak) 01/01: Revert "OAK-11248 : closing all features in one single loop"

Posted by st...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

stefanegli pushed a commit to branch revert-1845-OAK-11248
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git

commit 2ba4dfaca5b5d620d8e20b137f0fd68134f322b5
Author: stefan-egli <st...@apache.org>
AuthorDate: Wed Nov 6 21:31:05 2024 +0100

    Revert "OAK-11248 : closing all features in one single loop"
---
 .../plugins/document/DocumentNodeStoreService.java | 39 +++++++++++++---------
 .../document/DocumentNodeStoreServiceTest.java     | 17 ----------
 2 files changed, 23 insertions(+), 33 deletions(-)

diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
index 45484fc1f8..e77388d948 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
@@ -42,7 +42,6 @@ import java.util.Hashtable;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Predicate;
@@ -661,8 +660,29 @@ public class DocumentNodeStoreService {
             journalPropertyHandlerFactory.stop();
         }
 
-        closeFeatures(prefetchFeature, docStoreThrottlingFeature, cancelInvalidationFeature, docStoreFullGCFeature,
-                docStoreEmbeddedVerificationFeature, prevNoPropCacheFeature);
+        if (prefetchFeature != null) {
+            prefetchFeature.close();
+        }
+
+        if (docStoreThrottlingFeature != null) {
+            docStoreThrottlingFeature.close();
+        }
+
+        if (cancelInvalidationFeature != null) {
+            cancelInvalidationFeature.close();
+        }
+
+        if (docStoreFullGCFeature != null) {
+            docStoreFullGCFeature.close();
+        }
+
+        if (docStoreEmbeddedVerificationFeature != null) {
+            docStoreEmbeddedVerificationFeature.close();
+        }
+
+        if (prevNoPropCacheFeature != null) {
+            prevNoPropCacheFeature.close();
+        }
 
         unregisterNodeStore();
     }
@@ -768,19 +788,6 @@ public class DocumentNodeStoreService {
         }
     }
 
-    /**
-     * Closes the given varargs of features.
-     * <p>
-     * This method iterates over the provided varargs of features and closes each one
-     * that is not null.
-     * </p>
-     *
-     * @param features a varargs of {@link Feature} objects to be closed.
-     */
-    private void closeFeatures(@NotNull final Feature... features) {
-        Arrays.stream(features).filter(Objects::nonNull).forEach(Feature::close);
-    }
-
     private void unregisterNodeStore() {
         deactivationTimestamp = System.currentTimeMillis();
 
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreServiceTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreServiceTest.java
index 09af1fbdd0..c0fb2299ef 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreServiceTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreServiceTest.java
@@ -18,12 +18,10 @@ package org.apache.jackrabbit.oak.plugins.document;
 
 import java.io.File;
 import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.Supplier;
 
-import org.apache.commons.lang3.reflect.MethodUtils;
 import org.apache.jackrabbit.guava.common.collect.Maps;
 import com.mongodb.MongoClient;
 
@@ -33,7 +31,6 @@ import org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStoreTestHe
 import org.apache.jackrabbit.oak.plugins.document.spi.JournalPropertyService;
 import org.apache.jackrabbit.oak.plugins.document.spi.lease.LeaseFailureHandler;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
-import org.apache.jackrabbit.oak.spi.toggle.Feature;
 import org.apache.jackrabbit.oak.stats.StatisticsProvider;
 import org.apache.sling.testing.mock.osgi.MockOsgi;
 import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
@@ -48,7 +45,6 @@ import static org.apache.jackrabbit.oak.plugins.document.Configuration.PID;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.junit.Assume.assumeTrue;
@@ -360,19 +356,6 @@ public class DocumentNodeStoreServiceTest {
         doRecoveryDelayMillis(60000);
     }
 
-    @Test
-    public void closeFeatures() throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
-        Feature feature1 = mock(Feature.class);
-        Feature feature2 = mock(Feature.class);
-        Feature feature3 = mock(Feature.class);
-        Feature feature4 = mock(Feature.class);
-
-        // successful invocation would return null
-        assertNull(MethodUtils.invokeMethod(service, true, "closeFeatures",
-                new Object[]{feature1, feature2, null, feature3, feature4},
-                new Class[]{Feature[].class}));
-    }
-
     private void doRecoveryDelayMillis(long recoveryDelayMillis) {
         Map<String, Object> config = newConfig(repoHome);
         config.put("recoveryDelayMillis", recoveryDelayMillis);