reschke commented on code in PR #136:
URL: 
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/136#discussion_r1927658085


##########
src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java:
##########
@@ -149,6 +154,36 @@ public void setup() throws Exception {
         Optional<ResourceResolverMetrics> metrics = Optional.empty();
 
         mapEntries = new MapEntries(resourceResolverFactory, bundleContext, 
eventAdmin, stringInterpolationProvider, metrics);
+        waitForBgInit();
+    }
+
+    // get internal flag that signals completion of background task
+    private AtomicBoolean getVanityPathsProcessed() {
+        try {
+            Field field = 
MapEntries.class.getDeclaredField("vanityPathsProcessed");
+            field.setAccessible(true);
+            return (AtomicBoolean) field.get(mapEntries);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    // wait for background thread to complete
+    private void waitForBgInit() {
+        while (!getVanityPathsProcessed().get()) {
+            try {
+                Thread.sleep(10);
+            } catch (InterruptedException e) {
+                // ignored
+            }
+        }
+    }
+
+    // get vanity paths (after waiting for bg init to complete)
+    private void initializeVanityPaths() throws IOException {
+        getVanityPathsProcessed().set(false);
+        mapEntries.initializeVanityPaths();
+        waitForBgInit();

Review Comment:
   The tests (now) run with bginit as well, see parameters of the test class.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to