WebComponentConfigurationRegistry implements Serializable { public boolean setConfigurations( Set<WebComponentConfiguration<? extends Component>> configurations) { lock(); try { if (configurationsSet) { return false; } configurationsSet = true; updateRegistry(configurations); return true; } finally { unlock(); } } protected  WebComponentConfigurationRegistry(); Optional<WebComponentConfiguration<? extends Component>> getConfiguration(
            String tag); @SuppressWarnings("unchecked") Set<WebComponentConfiguration<T>> getConfigurationsByComponentType(
            Class<T> componentClass); boolean setConfigurations(
            Set<WebComponentConfiguration<? extends Component>> configurations); boolean hasConfigurations(); Optional<T> getEmbeddedApplicationAnnotation(
            Class<T> type); Set<WebComponentConfiguration<? extends Component>> getConfigurations(); void setShadowDomElements(List<Element> elements); List<Element> getShadowDomElements(); static WebComponentConfigurationRegistry getInstance(
            VaadinContext context);  }
@Test public void setSameRouteValueFromDifferentThreads_ConcurrencyTest() throws InterruptedException, ExecutionException { final int THREADS = 10; ExecutorService executorService = Executors.newFixedThreadPool(THREADS); List<Callable<AtomicBoolean>> callables = IntStream.range(0, THREADS) .mapToObj(i -> { Callable<AtomicBoolean> callable = () -> { Thread.sleep(new Random().nextInt(200)); return new AtomicBoolean( registry.setConfigurations(createConfigurations( MyComponentExporter.class))); }; return callable; }).collect(Collectors.toList()); List<Future<AtomicBoolean>> futures = executorService .invokeAll(callables); executorService.shutdown(); Assert.assertEquals("Expected a result for all threads", THREADS, futures.size()); List<AtomicBoolean> results = new ArrayList<>(); for (Future<AtomicBoolean> resultFuture : futures) { results.add(resultFuture.get()); } Assert.assertEquals("Expected all except one thread to return false", THREADS - 1, results.stream().filter(result -> !result.get()).count()); }