You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2021/04/29 16:29:04 UTC

[sling-org-apache-sling-resourceresolver] branch master updated: SLING-10346 make sure timer is only accessed when not null (as it is when vanitypath is disabled via configuration)

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

sseifert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git


The following commit(s) were added to refs/heads/master by this push:
     new a19b2c2  SLING-10346 make sure timer is only accessed when not null (as it is when vanitypath is disabled via configuration)
a19b2c2 is described below

commit a19b2c2474ae0165e35bce94ecad5e3d23873549
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Thu Apr 29 18:28:19 2021 +0200

    SLING-10346 make sure timer is only accessed when not null (as it is when vanitypath is disabled via configuration)
---
 .../sling/resourceresolver/impl/mapping/MapEntries.java     |  4 +++-
 .../sling/resourceresolver/impl/mapping/MapEntriesTest.java | 13 +++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
index 2608119..4240875 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
@@ -527,7 +527,9 @@ public class MapEntries implements
      */
     public void dispose() {
 
-        timer.cancel();
+        if (timer != null) {
+            timer.cancel();
+        }
 
         persistBloomFilter();
 
diff --git a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java
index 9672020..92310e4 100644
--- a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java
+++ b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java
@@ -83,6 +83,7 @@ public class MapEntriesTest extends AbstractMappingMapEntriesTest {
     private Map<String, Map<String, String>> aliasMap;
     private int testSize = 5;
 
+    @Override
     @SuppressWarnings({ "unchecked" })
     @Before
     public void setup() throws Exception {
@@ -131,8 +132,10 @@ public class MapEntriesTest extends AbstractMappingMapEntriesTest {
         this.aliasMap = ( Map<String, Map<String, String>>) aliasMapField.get(mapEntries);
     }
 
+    @Override
     @After
     public void tearDown() throws Exception {
+        mapEntries.dispose();
         vanityBloomFilterFile.delete();
     }
 
@@ -2107,4 +2110,14 @@ public class MapEntriesTest extends AbstractMappingMapEntriesTest {
         mapEntries.doInit();
     }
 
+    @Test
+    public void test_vanitypath_disabled() throws Exception {
+        // initialize with having vanity path disabled - must not throw errors here or on disposal
+        when(resourceResolverFactory.isVanityPathEnabled()).thenReturn(false);
+
+        mapEntries = new MapEntries(resourceResolverFactory, bundleContext, eventAdmin, stringInterpolationProvider);
+
+        mapEntries.doInit();
+    }
+
 }
\ No newline at end of file