public String saveMappings()

in src/main/java/org/apache/sling/launchpad/testservices/exported/MappingsFacade.java [54:77]


    public String saveMappings(Session session) throws Exception {
        final int oldEventsCount = eventsCounter.getEventsCount(MAPPING_EVENT_TOPIC);
        logger.debug(
                "Saving Session and waiting for event counter {} to change from current value {}",
                MAPPING_EVENT_TOPIC,
                oldEventsCount);
        session.save();
        final long timeout = System.currentTimeMillis() + updateTimeout;
        while (System.currentTimeMillis() < timeout) {
            final int newCount = eventsCounter.getEventsCount(MAPPING_EVENT_TOPIC);
            if (newCount != oldEventsCount) {
                // Sleeping here shouldn't be needed but it looks
                // like mappings are not immediately updated once the event arrives
                logger.debug("Event counter {} is now {}", MAPPING_EVENT_TOPIC, newCount);
                Thread.sleep(updateTimeout / 50);
                return null;
            }
            try {
                Thread.sleep(10);
            } catch (InterruptedException ignore) {
            }
        }
        return "Timeout waiting for " + MAPPING_EVENT_TOPIC + " event, after " + updateTimeout + " msec";
    }