]> source.dussan.org Git - vaadin-framework.git/commitdiff
Improve thread safety (#12395)
authorTatu Lund <tatu@vaadin.com>
Wed, 8 Sep 2021 11:58:15 +0000 (14:58 +0300)
committerGitHub <noreply@github.com>
Wed, 8 Sep 2021 11:58:15 +0000 (14:58 +0300)
See: https://vaadin.com/forum/thread/17522264/concurrentmodificationexception-in-vaadin-shared-on-karaf-4-2-x

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);
+            }
         }
     }