Ext


Go Back   Ext JS Forums > Ext GWT Community Forums (1.x) > Gxt: Bugs (1.x)

Reply
 
Thread Tools
  #1  
Old 07-22-2008, 09:37 AM
brom38 brom38 is offline
Ext User
 
Join Date: Dec 2007
Posts: 1
brom38 is on a distinguished road
Default [FIXED] Store commit/reject changes bug

When I try commit or reject changes for "dirty" Store I recieve java.util.ConcurrentModificationException.

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);
  }
Reply With Quote
  #2  
Old 07-22-2008, 11:27 AM
darrellmeyer's Avatar
darrellmeyer darrellmeyer is offline
Ext GWT - Development Team
 
Join Date: May 2007
Location: Washington, DC
Posts: 1,973
darrellmeyer is on a distinguished road
Default

Fix is in SVN.
Reply With Quote
  #3  
Old 10-22-2009, 08:25 AM
tikvar tikvar is offline
Ext User
 
Join Date: Apr 2008
Posts: 10
tikvar is on a distinguished road
Default [2.0.1] ConcurrentModiificationException in Record.reject()

I came across the same issue in Record:

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);
        ...
      }

    }
    ...
  }
To fix the issue, just make a copy of the keyset before iterating over it:
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));
      }
    }
    ...
  }
Reply With Quote
  #4  
Old 11-02-2009, 12:39 PM
darrellmeyer's Avatar
darrellmeyer darrellmeyer is offline
Ext GWT - Development Team
 
Join Date: May 2007
Location: Washington, DC
Posts: 1,973
darrellmeyer is on a distinguished road
Default

Fixed in trunk. Change will be available in 2.1 release.
Reply With Quote
Reply

Thread Tools

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

All times are GMT -5. The time now is 07:08 AM.

© 2006-2009 Ext, LLC
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.