Repository: zeppelin
Updated Branches:
  refs/heads/master 8f344db93 -> b8755ebb2


ZEPPELIN-1420. java.util.ConcurrentModificationException caused by calling 
remove inside foreach loop

### What is this PR for?
We should use Iterator to iterate the list when we want to remove items in the 
middle of iteration, Otherwise will get the ConcurrentModificationException

### What type of PR is it?
[Bug Fix]

### Todos
* [ ] - Task

### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-1420

### How should this be tested?
No test added

### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No

Author: Jeff Zhang <zjf...@apache.org>

Closes #1419 from zjffdu/ZEPPELIN-1420 and squashes the following commits:

ddd0710 [Jeff Zhang] ZEPPELIN-1420. java.util.ConcurrentModificationException 
caused by calling remove inside foreach loop


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/b8755ebb
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/b8755ebb
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/b8755ebb

Branch: refs/heads/master
Commit: b8755ebb25ad793daa6873acc2e00b8d69588188
Parents: 8f344db
Author: Jeff Zhang <zjf...@apache.org>
Authored: Fri Sep 9 14:41:26 2016 +0800
Committer: Alexander Bezzubov <b...@apache.org>
Committed: Mon Sep 19 16:07:37 2016 +0900

----------------------------------------------------------------------
 .../zeppelin/interpreter/InterpreterFactory.java | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/b8755ebb/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java
 
b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java
index 362f76c..7732a45 100644
--- 
a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java
+++ 
b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java
@@ -1017,15 +1017,16 @@ public class InterpreterFactory implements 
InterpreterGroupFactory {
   public List<InterpreterSetting> getInterpreterSettings(String noteId) {
     List<String> interpreterSettingIds = 
getNoteInterpreterSettingBinding(noteId);
     LinkedList<InterpreterSetting> settings = new LinkedList<>();
-    synchronized (interpreterSettingIds) {
-      for (String id : interpreterSettingIds) {
-        InterpreterSetting setting = get(id);
-        if (setting == null) {
-          // interpreter setting is removed from factory. remove id from here, 
too
-          interpreterSettingIds.remove(id);
-        } else {
-          settings.add(setting);
-        }
+
+    Iterator<String> iter = interpreterSettingIds.iterator();
+    while (iter.hasNext()) {
+      String id = iter.next();
+      InterpreterSetting setting = get(id);
+      if (setting == null) {
+        // interpreter setting is removed from factory. remove id from here, 
too
+        iter.remove();
+      } else {
+        settings.add(setting);
       }
     }
     return settings;

Reply via email to