Success! Looks like we've fixed this one. According to our records the fix was applied for EXTGWT-2703 in a recent build.
  1. #1
    Sencha Premium Member
    Join Date
    Nov 2012
    Location
    Cremona Italy
    Posts
    37
    Vote Rating
    2
    info@csamed.it is on a distinguished road

      0  

    Default [GXT3.0.3] ListStore<T> .addAll(list<T>) with list.size = 0 throws exception

    [GXT3.0.3] ListStore<T> .addAll(list<T>) with list.size = 0 throws exception


    As title says, I just updated from GXT .2b to .3 and everytime I make this operation

    Code:
    public void success(List<T_DTO> result) {
    storeT.clear(); //this is a ListStore<T> for a grid
    storeT.addAll(result);
    storeT.commitChanges();
    //other code...
    }
    I get this exception

    Code:
    java.lang.AssertionError: null
        at com.sencha.gxt.data.shared.event.StoreAddEvent.<init>(StoreAddEvent.java:84)
        at com.sencha.gxt.data.shared.ListStore.addAll(ListStore.java:178)
        at com.sencha.gxt.data.shared.ListStore.addAll(ListStore.java:124)
        at fatturazione.client.bolle.SchermataBolle$4.success(SchermataBolle.java:274)
        at fatturazione.client.bolle.SchermataBolle$4.success(SchermataBolle.java:1)
        at fatturazione.client.ExtAsyncCallback.onSuccess(ExtAsyncCallback.java:15)
        at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:232)
        at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
        at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
        at sun.reflect.GeneratedMethodAccessor71.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
        at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
        at sun.reflect.GeneratedMethodAccessor61.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
        at java.lang.Thread.run(Unknown Source)
    until I wrap ".addAll()" with a "if(result.size()>0)".
    Looking in the library, in the StoreAddEvent.class I've found

    Code:
    public StoreAddEvent(int index, List<M> items) {
        assert items.size() != 0; 
        this.index = index;
        this.items = Collections.unmodifiableList(items);
      }
    This should explain everything, but I never had such problem before.
    Is this meant? because I haven't seen any reference in the patch notes.

    I've been around the forums for some time and that's my first post, so I just wanted to thank all the staff for the awesome work they did and they are doing: keep going!
    Thanks for the replies.

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,732
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      1  

    Default


    Thanks for the report - I added that assertion myself in dealing with a TreeStore issue (see http://www.sencha.com/forum/showthread.php?235044 for more details on that) along with a check in the TreeStore that we never emit events for zero items added. I should have also made a change in ListStore to check that we don't fire events for no items added.

    This bug should only occur when you actually add an empty list to the ListStore using addAll - if you add a list with invisible items, no event should be emitted. I can add a check for this, but the idea of adding an empty list confuses me a bit - what is the use case here?

    The workaround you've provided is one option to stop this from happening. Another could be to disable all assertions: I think the flag is -da, passed as a JVM arg. Be careful when doing this though - we've added a number of helpful assertions, and plan on adding more to assist in debugging.

    The real fix for this seems to be checking if the user passed in an empty list (the same check as you made) and not doing anything, though it'd be my preference to not do that on every single addAll call - its not too expensive, but that can already be an expensive method.

  3. #3
    Sencha Premium Member
    Join Date
    Nov 2012
    Location
    Cremona Italy
    Posts
    37
    Vote Rating
    2
    info@csamed.it is on a distinguished road

      1  

    Default


    Hi colin,
    thanks for the fast reply!
    In my case, I just retrive via RPC a list of DTOs to be displayed in my table, eventually filtered.
    Server side I've Spring+Hibernate and when I create a criteria that should not return a thing, a List of size=0 is returned,which is passed to a braindead DTO<->Entity converter and sent to client.
    It wasn't a big deal to add this control for every table's data-load: forced me to add some extra check in my code, but still was very unespected (looping a non null list of size 0 should output just silence).
    Anyway, let us know how this will be dealt.
    Thank you so much again.

  4. #4
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    39
    Vote Rating
    2
    hcr is on a distinguished road

      1  

    Default


    Hi,

    I haven't had this problem yet (only because we haven't updated to 3.0.3) and just stumbled upon this thread by coincidence. I think the OP's point is perfectly valid -- we, too, return DTOs based on search criterias to the user and sometimes they don't match any records and return an empty list.

    In my opinion, this assertion is misplaced here. Adding an empty list to a grid's list store should be allowed.

    best regards,
    -hcr-

  5. #5
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,732
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    I agree that the assertion shouldn't be failing in this case, but I definitely like the assertion where it is. GXT 3's ListStore tries to look more like List, though we dont get all of these exactly right, but we can get this one right.

    The assertion means 'Someone fired an event that means that nothing as added - this is useless and should be stopped'. The real error that the assertion has uncovered is that ListStore.addAll should do nothing.

    I'm moving this to the bugs forum and filing it internally so we can deal with it. There are two workarounds already posted here, and we'll update this when fixed.

  6. #6
    Sencha User
    Join Date
    Dec 2010
    Location
    Bangalore, India
    Posts
    10
    Vote Rating
    0
    dineshv87 is on a distinguished road

      0  

    Default


    It seems to be we cannot run gwt devmode with assertions disabled (Source : link ). Assertions are enabled in code level as per the implementation of CompilingClassLoader . Has anyone succeeded with running gwt devmode with assertions disabled?

    Is there any other simple work around to fix this issue without having additional size check everywhere?

  7. #7
    Sencha Premium Member
    Join Date
    Feb 2011
    Posts
    134
    Vote Rating
    1
    bluemartini is on a distinguished road

      0  

    Default


    It seems to be we cannot run gwt devmode with assertions disabled (Source : link ). Assertions are enabled in code level as per the implementation of CompilingClassLoader . I have tried passing -da in jvm arguments. But no luck.

    Has anyone succeeded with running gwt devmode with assertions disabled?

    Is there any other simple work around to fix this issue without having additional size check everywhere?

  8. #8
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,732
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    Thanks - I was unaware of that. I've tried, without any luck, to find a simple way of working around this - I can think of 2 complex ways, but am hoping to slim one down before I propose it.

    You can extend and patch ListStore pretty easily - only addAll is susceptible to this issue. This could look like this:
    Code:
    public class PatchedListStore<M> extends ListStore<M> {
      public PatchedListStore(ModelKeyProvider<? super M> keyProvider) {
        super(keyProvider);
      }
    
      @Override
      public boolean addAll(int index, Collection<? extends M> items) {
        if (items.isEmpty()) {
          return false;
        }
        return super.addAll(index, items);
      }
    }
    This is essentially the fix that is being made in SVN - it hasn't yet been accepted, as other developers are on break, and haven't yet reviewed my patch.

  9. #9
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,732
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    This has been fixed in SVN, along with unit tests to ensure this doesn't pop up again. This will be available in tonight's nightly build, and will be present in the next release.