tailorlala / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

RegularImmutableAsList CustomFieldSerializer depends on RegularImmutableSet but did not include it into Serializationpolicy #1841

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
if you have a RemoteService with only 1 method and the signature:

    void testImmutableList(ImmutableList<String> list);

and you call it with

    testImmutableList(ImmutableSet.of("a", "b").asList())

you will get an exception:

    com.google.gwt.user.client.rpc.SerializationException: Type 'com.google.common.collect.RegularImmutableSet' was not included in the set of types which can be deserialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be deserialized.
        at com.google.gwt.user.server.rpc.impl.StandardSerializationPolicy.validateDeserialize(StandardSerializationPolicy.java:158)

this happens because the delegate of RegularImmutableAsList is a 
RegularImmutableSet which is not included into the serialization policy but is 
written by the RegularImmutableAsList_CustomFieldSerializer

    writer.writeObject(instance.delegateCollection());
    writer.writeObject(instance.delegateList());

Original issue reported on code.google.com by jbj...@gmail.com on 3 Sep 2014 at 9:52

GoogleCodeExporter commented 9 years ago
you have to call the RemoteServiceAsync which looks like

    testImmutableList(ImmutableSet.of("a", "b").asList(), new AsyncCallbacl<Void>() { ... });

Original comment by jbj...@gmail.com on 3 Sep 2014 at 9:54

GoogleCodeExporter commented 9 years ago
That's bad :(

The workaround is to do something like ImmutableList.copyOf(new 
ArrayList<>(set)), but of course that's not something that we should make you 
do.

Under the current GWT serialization implementation, this is hard (impossible?) 
to fix without requiring everyone who serializes ImmutableList to have every 
possible implementation available on the client side. Some clients don't like 
the resulting bloat. To avoid that, we'd ideally like for GWT to implement 
https://code.google.com/p/google-web-toolkit/issues/detail?id=8844

A possible alternative that I've been considering is for us to have a single 
ImmutableList class that delegates all its implementation to an 
ImmutableListImpl class. This would allow us to have a single ImmutableList 
serializer for all ImmutableLists. The downside is indirection and extra memory 
on the server. It's hard to know how much that would cost. One day I hope to 
look into this. Until then, we're unlikely to do much here, barring new ideas. 
Sorry that I don't have something more immediate for you.

Original comment by cpov...@google.com on 3 Sep 2014 at 12:20

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
We have overriden the CustomFieldSerializer with our own implementation and the 
problem is solved.

Original comment by jbj...@gmail.com on 8 Sep 2014 at 2:35

Attachments:

GoogleCodeExporter commented 9 years ago
Clever! I think we'll do it.

Original comment by cpov...@google.com on 8 Sep 2014 at 8:25

GoogleCodeExporter commented 9 years ago
I'd be happy to take the revised version directly, but we'd need your legal 
permission:

https://developers.google.com/open-source/cla/individual
or:
https://developers.google.com/open-source/cla/corporate

Let me know whether you'd like to do that. Otherwise, I'll figure out what we 
can do to implement things from scratch.

Original comment by cpov...@google.com on 8 Sep 2014 at 8:37

GoogleCodeExporter commented 9 years ago
Have you found any decision on whether the patch is something you can 
officially/legally contribute? Thanks.

Original comment by cpov...@google.com on 1 Oct 2014 at 6:27

GoogleCodeExporter commented 9 years ago
It can be contributed, with your own header, sorry for the late answer

Original comment by jbj...@gmail.com on 25 Oct 2014 at 7:16

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<issue id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:08

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:17

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:07