it looks like http://code.google.com/p/google-web-toolkit/issues/detail?id=6354
Alexandre. 2011/6/20 Alexandre Ardhuin <[email protected]> > Hi all, > > I face a very strange behavior on requestFactory with GWT-2.3. > Sometimes, java.util.Set<T> collections are not deserialized as expected > (java.util.List<T> works well). Some elements are missing. > > Here's the code that illustrates the problem : > > // ---------------------------------- > // ----------- client side code > // ---------------------------------- > > @Service(value = MyService.class, locator = MyLocator.class) > public interface MyRequest extends RequestContext { > Request<MyObjectProxy> getMyObject(int count); > } > > @ProxyFor(value = MyObject.class) > public interface MyObjectProxy extends ValueProxy { > int getExpectedSize(); > Set<StringContainerProxy> getStringContainers(); > } > > @ProxyFor(value = StringContainer.class) > public interface StringContainerProxy extends ValueProxy { > String getString(); > } > > // ---------------------------------- > // ------------ server side code > // ---------------------------------- > > public class MyLocator implements ServiceLocator { > @Override > public Object getInstance(final Class<?> clazz) { return new > MyService(); } > } > > public class MyService { > public MyObject getMyObject(int count) { > final Set<StringContainer> stringContainers = new > HashSet<StringContainer>(); > for (int i = 0; i < count; i++) { > stringContainers.add(new StringContainer(String.valueOf(i))); > } > return new MyObject(stringContainers.size(), stringContainers); > } > } > > public class MyObject { > private final int expectedSize; > private final Set<StringContainer> stringContainers; > > public MyObject(int expectedSize, Set<StringContainer> > stringContainers) { this.expectedSize = expectedSize; this.stringContainers > = stringContainers; } > public int getExpectedSize() { return expectedSize; } > public Set<StringContainer> getStringContainers() { return > stringContainers; } > } > > public class StringContainer { > private final String string; > > public StringContainer(String string) { this.string = string; } > public String getString() { return string; } > } > > > // ---------------------------------- > // ------------ entry point that show different sizes > // ---------------------------------- > > public class MainPage implements EntryPoint { > public void onModuleLoad() > { > final ClientFactory clientFactory = > GWT.create(ClientFactory.class); > clientFactory.init(); > call(clientFactory, 0); > } > > private void call(final ClientFactory clientFactory, final int i) > { > if (i > 100) { > return; > } > > clientFactory.getRequestFactory().myRequest().getMyObject(i).fire(new > Receiver<MyObjectProxy>() { > @Override > public void onSuccess(MyObjectProxy response) { > RootPanel.get().add(new HTML(response.getExpectedSize() + " > " + response.getStringContainers().size())); > call(clientFactory, i + 1); > } > }); > } > } > > Here's the results for the 30 first requests (left is the expected size, > right is the real size) : > 0 0 > 1 1 > 2 2 > 3 3 > 4 4 > 5 5 > 6 6 > 7 7 > 8 8 > 9 9 > 10 10 > 11 11 > 12 4 // problems start here... > 13 4 > 14 4 > 15 4 > 16 4 > 17 4 > 18 4 > 19 4 > 20 4 > 21 4 > 22 4 > 23 9 > 24 10 > 25 11 > 26 12 > 27 13 > 28 14 > 29 14 > 30 14 > > > Using java.util.List instead of java.util.Set resolves the problem. > > Did i miss something ? > > Alexandre. > > -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
