Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha Premium Member
    Join Date
    Mar 2012
    Posts
    75
    Vote Rating
    2
    tby is on a distinguished road

      0  

    Default ListStore throws NPE when null values present

    ListStore throws NPE when null values present


    The ListStore throws a NPE when the underlying list contains a null value when removing the ListStore filters:
    Code:
    Caused by: java.lang.NullPointerException: null
        at com.sencha.gxt.data.shared.ListStore.findModelWithKey(ListStore.java:193)
        at com.sencha.gxt.data.shared.Store.findModel(Store.java:593)
        at com.sencha.gxt.widget.core.client.selection.AbstractStoreSelectionModel.refresh(AbstractStoreSelectionModel.java:242)
        at com.sencha.gxt.widget.core.client.ListViewSelectionModel$Handler.onRefresh(ListViewSelectionModel.java:95)
        at com.sencha.gxt.widget.core.client.event.RefreshEvent.dispatch(RefreshEvent.java:48)
        at com.sencha.gxt.widget.core.client.event.RefreshEvent.dispatch(RefreshEvent.java:1)
        at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
        at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
        at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
        at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
        at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
        at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129)
        at com.sencha.gxt.widget.core.client.Component.fireEvent(Component.java:291)
        at com.sencha.gxt.widget.core.client.ListView.refresh(ListView.java:557)
        at com.sencha.gxt.widget.core.client.ListView$1.onFilter(ListView.java:292)
        at com.sencha.gxt.data.shared.event.StoreFilterEvent.dispatch(StoreFilterEvent.java:77)
        at com.sencha.gxt.data.shared.event.StoreFilterEvent.dispatch(StoreFilterEvent.java:1)
        at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
        at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
        at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
        at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
        at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
        at com.sencha.gxt.data.shared.Store.fireEvent(Store.java:608)
        at com.sencha.gxt.data.shared.ListStore.applyFilters(ListStore.java:361)
        at com.sencha.gxt.data.shared.Store.removeFilters(Store.java:757)

  2. #2
    Sencha - GXT Dev Team darrellmeyer's Avatar
    Join Date
    May 2007
    Location
    Washington, DC
    Posts
    2,242
    Vote Rating
    2
    darrellmeyer is on a distinguished road

      0  

    Default


    We have looked into the issue but need more information to proceed. Can you please provide some test code that we can run which demonstrates the issue?

  3. #3
    Sencha Premium Member
    Join Date
    Mar 2012
    Posts
    75
    Vote Rating
    2
    tby is on a distinguished road

      0  

    Default


    ...
    ListStore<Entry> store = new ListStore<Entry>(new ModelKeyProvider<Entry>() {


    @Override
    public String getKey(Entry pItem) {
    if (pItem == null) {
    return null;
    } else {
    return pItem.getName();
    }
    }
    });


    store.add(null); // Add a null value to the store


    Entry e = new Entry();
    e.setName("Entry 1");
    store.add(e);


    e = new Entry();
    e.setName("Entry 2");
    store.add(e);


    store.findModel(e); // Throws NPE


    ...
    }




    public class Entry {
    private String name;


    public String getName() {
    return name;
    }


    public void setName(String name) {
    this.name = name;
    }


    }

  4. #4
    Sencha - GXT Dev Team darrellmeyer's Avatar
    Join Date
    May 2007
    Location
    Washington, DC
    Posts
    2,242
    Vote Rating
    2
    darrellmeyer is on a distinguished road

      0  

    Default


    Null keys are not supported. I have updated the docs for getKey to document keys may not be null.

Thread Participants: 1