Repository: aries-jax-rs-whiteboard
Updated Branches:
  refs/heads/master d58f58e0d -> 82f6bfb8f


Fix concurrent modification exception


Project: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/commit/82f6bfb8
Tree: 
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/82f6bfb8
Diff: 
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/82f6bfb8

Branch: refs/heads/master
Commit: 82f6bfb8f5bb8276bd989670822e1ee6faf31f64
Parents: d58f58e
Author: Carlos Sierra <csie...@apache.org>
Authored: Fri May 18 08:37:17 2018 +0200
Committer: Carlos Sierra <csie...@apache.org>
Committed: Fri May 18 08:37:17 2018 +0200

----------------------------------------------------------------------
 .../internal/ApplicationExtensionRegistry.java        |  8 +++++---
 .../jax/rs/whiteboard/internal/ExtensionRegistry.java | 14 ++++++++++----
 2 files changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/82f6bfb8/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ApplicationExtensionRegistry.java
----------------------------------------------------------------------
diff --git 
a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ApplicationExtensionRegistry.java
 
b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ApplicationExtensionRegistry.java
index 17cb4d6..c399e40 100644
--- 
a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ApplicationExtensionRegistry.java
+++ 
b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ApplicationExtensionRegistry.java
@@ -75,7 +75,9 @@ public class ApplicationExtensionRegistry implements 
AutoCloseable {
                     _applicationRegisteredExtensions.get(applicationName);
 
                 if (extensions != null) {
-                    for (CachingServiceReference<?> extension : extensions) {
+                    for (CachingServiceReference<?> extension :
+                        new HashSet<>(extensions)) {
+
                         aep.publishIfMatched(extension);
                     }
                 }
@@ -109,7 +111,7 @@ public class ApplicationExtensionRegistry implements 
AutoCloseable {
                 _applicationPublishers.get(applicationName);
 
             if (publishers != null) {
-                for (FilteredPublisher publisher : publishers) {
+                for (FilteredPublisher publisher : new HashSet<>(publishers)) {
                     publisher.publishIfMatched(extension);
                 }
             }
@@ -137,7 +139,7 @@ public class ApplicationExtensionRegistry implements 
AutoCloseable {
                 _applicationPublishers.get(applicationName);
 
             if (publishers != null) {
-                for (FilteredPublisher publisher : publishers) {
+                for (FilteredPublisher publisher : new HashSet<>(publishers)) {
                     publisher.retractIfMatched(extension);
                 }
             }

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/82f6bfb8/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ExtensionRegistry.java
----------------------------------------------------------------------
diff --git 
a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ExtensionRegistry.java
 
b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ExtensionRegistry.java
index fe91959..e67ce23 100644
--- 
a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ExtensionRegistry.java
+++ 
b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ExtensionRegistry.java
@@ -36,7 +36,9 @@ public class ExtensionRegistry implements AutoCloseable {
 
     @Override
     public void close() {
-        for (FilteredPublisher extensionPublisher : _extensionPublishers) {
+        for (FilteredPublisher extensionPublisher :
+            new HashSet<>(_extensionPublishers)) {
+
             extensionPublisher.close();
         }
     }
@@ -60,7 +62,7 @@ public class ExtensionRegistry implements AutoCloseable {
                 _extensionPublishers.add(ep);
 
                 for (CachingServiceReference<?> extension :
-                    _registeredExtensions) {
+                    new HashSet<>(_registeredExtensions)) {
 
                     ep.publishIfMatched(extension);
                 }
@@ -85,7 +87,9 @@ public class ExtensionRegistry implements AutoCloseable {
         CachingServiceReference<?> extension) {
 
         synchronized (ExtensionRegistry.this) {
-            for (FilteredPublisher publisher : _extensionPublishers) {
+            for (FilteredPublisher publisher :
+                new HashSet<>(_extensionPublishers)) {
+
                 publisher.publishIfMatched(extension);
             }
 
@@ -97,7 +101,9 @@ public class ExtensionRegistry implements AutoCloseable {
         CachingServiceReference<?> extension) {
 
         synchronized (ExtensionRegistry.this) {
-            for (FilteredPublisher publisher : _extensionPublishers) {
+            for (FilteredPublisher publisher :
+                new HashSet<>(_extensionPublishers)) {
+
                 publisher.retractIfMatched(extension);
             }
 

Reply via email to