]> source.dussan.org Git - vaadin-framework.git/commitdiff
Improve thread safety (#12395) (#12417)
authorOlli Tietäväinen <ollit@vaadin.com>
Tue, 5 Oct 2021 06:36:52 +0000 (09:36 +0300)
committerGitHub <noreply@github.com>
Tue, 5 Oct 2021 06:36:52 +0000 (09:36 +0300)
See: https://vaadin.com/forum/thread/17522264/concurrentmodificationexception-in-vaadin-shared-on-karaf-4-2-x

Co-authored-by: Tatu Lund <tatu@vaadin.com>
shared/src/main/java/com/vaadin/osgi/resources/impl/VaadinResourceTrackerComponent.java

index 330e5f44e8587abe2983895dbce33ff62765ceda..49d66321eaa0c691069c33a6c57b39391613bac2 100644 (file)
@@ -151,9 +151,11 @@ public class VaadinResourceTrackerComponent {
      */
     @Activate
     protected void activate(BundleContext context) {
-        vaadinSharedContext = context;
-        for (Delegate<?> registration : resourceToRegistration.values()) {
-            registration.register(vaadinSharedContext, vaadinService);
+        synchronized (resourceToRegistration) {
+            vaadinSharedContext = context;
+            for (Delegate<?> registration : resourceToRegistration.values()) {
+                registration.register(context, vaadinService);
+            }
         }
     }