This is an automated email from the ASF dual-hosted git repository. daim pushed a commit to branch OAK-11248 in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit db13a89a1dbb951fa5ae057af1b46178af04116e Author: Rishabh Kumar <[email protected]> AuthorDate: Wed Nov 6 11:28:17 2024 +0530 OAK-11248 : closing all features in one single loop --- .../plugins/document/DocumentNodeStoreService.java | 39 +++++++++------------- 1 file changed, 16 insertions(+), 23 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 e77388d948..665a30d5f9 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,6 +42,7 @@ 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; @@ -660,29 +661,8 @@ public class DocumentNodeStoreService { journalPropertyHandlerFactory.stop(); } - 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(); - } + closeFeatures(new Feature[] {prefetchFeature, docStoreThrottlingFeature, cancelInvalidationFeature, + docStoreFullGCFeature, docStoreEmbeddedVerificationFeature, prevNoPropCacheFeature}); unregisterNodeStore(); } @@ -788,6 +768,19 @@ public class DocumentNodeStoreService { } } + /** + * Closes the given array of features. + * <p> + * This method iterates over the provided array of features and closes each one + * that is not null. + * </p> + * + * @param features an array of {@link Feature} objects to be closed. + */ + private void closeFeatures(final Feature[] features) { + Arrays.stream(features).filter(Objects::nonNull).forEach(Feature::close); + } + private void unregisterNodeStore() { deactivationTimestamp = System.currentTimeMillis();
