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


##########
src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java:
##########
@@ -1251,33 +1251,53 @@ public void test_bg_init_fallback_while_not_ready() {
             }
         });
 
-        assertEquals("test not started, query counter should be 0, queries 
were: " +
-                dumpQueries(queries), 0, queries.size());
+        Iterator<MapEntry> mit;
+        int expectedQueryCount = 0;
+        int expectedCacheHits = 0;
+        int expectedCacheMisses = 0;
 
-        mapEntries.vph.initializeVanityPaths();
-
-        assertEquals("test started, but query is blocked, query counter should 
still be 0, queries were: " +
-                dumpQueries(queries), 0, queries.size());
+        checkCounters("before tests",
+                queries, expectedQueryCount, expectedCacheHits, 
expectedCacheMisses);
 
-        // should not be finished until unlocked
-        assertFalse("VPH should not be ready as it is locked", 
mapEntries.vph.isReady());
+        mapEntries.vph.initializeVanityPaths();
+        assertFalse("VPH should not be ready until unblocked", 
mapEntries.vph.isReady());
+        checkCounters("after launch background it",
+                queries, expectedQueryCount, expectedCacheHits, 
expectedCacheMisses);
 
-        // do a forced lookup while init runs
-        Iterator<MapEntry> mit = 
mapEntries.vph.getCurrentMapEntryForVanityPath(targetPath);
-        assertNotNull(mit);
-        assertEquals("after lookup bypassing background init, exactly 1 query 
should have happened, but queries were: " +
-                dumpQueries(queries), 1, queries.size());
+        // do a forced lookup while background init runs, but is blocked
+        mit = mapEntries.vph.getCurrentMapEntryForVanityPath(targetPath);
+        // expectedCacheMisses += 1;

Review Comment:
   that was actually the thing that was flip-flopping between test executions; 
turned out that it really was supposed to increment but most of the times did 
not due to a race condition



-- 
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: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to