Skip to content

Commit

Permalink
Merge pull request #25 from paxdei/master
Browse files Browse the repository at this point in the history
Fix ConcurrentModificationException on removeAllMarkers()
Breaking change on getMarkers() -- now returns immutable java.util.Map rather than mutable java.util.HashMap

Change was required to remove possibility of concurrent modification without overhead of copying the map every time it was accessed.
  • Loading branch information
Ainsley committed Feb 6, 2016
2 parents d63229b + 0f3e657 commit ce28551
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions AceGWT/src/edu/ycp/cs/dh/acegwt/client/ace/AceEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@

package edu.ycp.cs.dh.acegwt.client.ace;

import java.util.HashMap;
import java.util.List;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.dom.client.Element;
Expand All @@ -32,6 +29,11 @@
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.RequiresResize;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* A GWT widget for the Ajax.org Code Editor (ACE).
*
Expand Down Expand Up @@ -702,17 +704,18 @@ public native void removeMarker(int markerId) /*-{

/**
* Gets all the displayed markers.
* @return A Mapping between markerID and the displayed range.
* @return An unmodifiable Mapping between markerID and the displayed range.
*/
public HashMap<Integer, AceRange> getMarkers() {
return this.markers;
public Map<Integer, AceRange> getMarkers() {
return Collections.unmodifiableMap(this.markers);
}

/**
* Remove all the displayed markers.
*/
public void removeAllMarkers() {
for (Integer id : this.markers.keySet()) {
Integer[] ids = this.markers.keySet().toArray(new Integer[this.markers.size()]);
for (Integer id : ids) {
removeMarker(id);
}
}
Expand Down

0 comments on commit ce28551

Please sign in to comment.