aboutsummaryrefslogtreecommitdiffstats
path: root/appc-oam/appc-oam-bundle/src/main/java/org/openecomp/appc/oam/util/AsyncTaskHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'appc-oam/appc-oam-bundle/src/main/java/org/openecomp/appc/oam/util/AsyncTaskHelper.java')
-rw-r--r--appc-oam/appc-oam-bundle/src/main/java/org/openecomp/appc/oam/util/AsyncTaskHelper.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/appc-oam/appc-oam-bundle/src/main/java/org/openecomp/appc/oam/util/AsyncTaskHelper.java b/appc-oam/appc-oam-bundle/src/main/java/org/openecomp/appc/oam/util/AsyncTaskHelper.java
index 0a4b868a8..9c344c14e 100644
--- a/appc-oam/appc-oam-bundle/src/main/java/org/openecomp/appc/oam/util/AsyncTaskHelper.java
+++ b/appc-oam/appc-oam-bundle/src/main/java/org/openecomp/appc/oam/util/AsyncTaskHelper.java
@@ -201,7 +201,11 @@ public class AsyncTaskHelper {
boolean cancel;
synchronized (AsyncTaskHelper.this) {
cancel = super.cancel(mayInterruptIfRunning);
- myFutureSet.stream().filter(f->!this.equals(f)).forEach(f->f.cancel(mayInterruptIfRunning));
+ //clone the set to prevent java.util.ConcurrentModificationException. The synchronized prevents
+ //other threads from modifying this set, but not itself. The f->f.cancel may modify myFutureSet by
+ //removing an entry which breaks the iteration in the forEach.
+ (new HashSet<MyFuture>(myFutureSet))
+ .stream().filter(f->!this.equals(f)).forEach(f->f.cancel(mayInterruptIfRunning));
}
return cancel;
}