rombert commented on code in PR #136:
URL:
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/136#discussion_r1928396494
##########
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);
Review Comment:
Why do you need to reset the internal state here?
--
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]