-
22 Jul 2008 5:37 AM #1
[FIXED] Store commit/reject changes bug
[FIXED] Store commit/reject changes bug
When I try commit or reject changes for "dirty" Store I recieve java.util.ConcurrentModificationException.
Code:com.extjs.gxt.ui.client.store.Store.java ... public void rejectChanges() { for (Record r : modified) { // iterate through "modified" list r.reject(false); // in this method fire: store.afterReject(this); } modified.clear(); } ... protected void afterReject(Record record) { modified.remove(record); // change "modified" list !!!! // in next iteration through "modified" list in rejectChanges() I recieve ConcurrentModificationException fireStoreEvent(Update, RecordUpdate.REJECT, record); }
-
22 Jul 2008 7:27 AM #2
Fix is in SVN.
-
22 Oct 2009 4:25 AM #3
[2.0.1] ConcurrentModiificationException in Record.reject()
[2.0.1] ConcurrentModiificationException in Record.reject()
I came across the same issue in Record:
To fix the issue, just make a copy of the keyset before iterating over it:Code:com.extjs.gxt.ui.client.store.Record.java ... public void reject(boolean silent) { if (modified != null) { for (String p : modified.keySet()) { model.set(p, modified.get(p)); // the call above this line leads (via FieldBinding) to a call to Record.set(p, modified.get(p)) // which changes the modified field and this results in ConcurrentModiificationException } } ... } public void set(String name, Object value) { ... if (!modified.containsKey(name)) { modified.put(name, model.get(name)); } else { Object origValue = modified.get(name); if ((origValue == null && value == null) || (origValue != null && origValue.equals(value))) { modified.remove(name); ... } } ... }
Code:com.extjs.gxt.ui.client.store.Record.java ... public void reject(boolean silent) { if (modified != null) { List<String> modifiedKeys = new ArrayList<String>(modified.keySet()); for (String p : modifiedKeys) { model.set(p, modified.get(p)); } } ... }
-
2 Nov 2009 9:39 AM #4
Fixed in trunk. Change will be available in 2.1 release.


Reply With Quote