GWT CustomFieldSerializer Recursivity

185 views
Skip to first unread message

Brandon Donnelson

unread,
Jan 2, 2013, 3:02:53 AM1/2/13
to google-we...@googlegroups.com
I've been trying to work on a custom serializer but I've not been able to get it to work. So I've been investigating com.google.gwt.user.server.rpc.impl.SerializabilityUtil. What I'm seeing is a strange recursive loop that looks odd to me. 

I can register a custom field serializer on next to the class or in the rpc core class and both produce the same result. But for this example I'll show the serializer looks like in the loop in rpc core.

class com.google.gwt.user.client.rpc.core.com.googlecode.objectify.impl.ref.StdRef_CustomFieldSerializer - finds the serializer on this iteration
class com.google.gwt.user.client.rpc.core.com.googlecode.objectify.impl.ref.StdRef_CustomFieldSerializer_CustomFieldSerializer - but on this one it looks for this and sets the mapping in this var to null in this map classServerCustomSerializerCache

During the second time it clears the setting in the cache too, which doesn't make sense to me. During the second time it sets the mapped serializer in this var to null, classServerCustomSerializerCache. Any idea if this is to be expected?

While I see it finds my custom field serializer in the code, I get stumped wondering why the code behaves as it does. Well anyway, my goal is to get the custom field serializer white listed, but I can't seem to get it registered. 

Brandon Donnelson


Colin Alworth

unread,
Jan 2, 2013, 10:38:36 AM1/2/13
to google-we...@googlegroups.com
It looks like it thinks you are sending the CustomFieldSerializer itself over the wire, so wants to find a serializer serializer... The extra prefixed package name "com.google.gwt.user.client.rpc.core" indicates that it wasn't able to find your field serializer in the normal package where it should be - consider knocking off that part and just make a com.googlecode.
objectify.impl.ref.StdRef_CustomFieldSerializer with the appropriate static methods.

In my brief re-read, I'm not seeing anywhere where the serializer gets passed in as a class to find another serializer for it - this fits with my previous experience where you just create a serializer and let RPC invoke it, no questions asked.

Brandon Donnelson

unread,
Jan 2, 2013, 12:16:36 PM1/2/13
to google-we...@googlegroups.com
Good point, but I don't think that's it. I walked the code several finding the loop on it self here: http://code.google.com/searchframe#T04cSGC7sWI/trunk/user/src/com/google/gwt/user/server/rpc/impl/SerializabilityUtil.java&q=SerializabilityUtil%20package:google-web-toolkit%5C.googlecode%5C.com&l=870 and the second time around it gets reset here: http://code.google.com/searchframe#T04cSGC7sWI/trunk/user/src/com/google/gwt/user/server/rpc/impl/SerializabilityUtil.java&q=SerializabilityUtil%20package:google-web-toolkit%5C.googlecode%5C.com&l=376

I don't have the *_CustomFieldSerializer in the translatable path either so it wouldn't be able to sent over the wire. But this I've found is only half of the recipe and  just checking the signature. So I'm looking at the generator or serialization oracle. 

Brandon

Thomas Broyer

unread,
Jan 2, 2013, 12:39:47 PM1/2/13
to google-we...@googlegroups.com


On Wednesday, January 2, 2013 6:16:36 PM UTC+1, Brandon Donnelson wrote:
Good point, but I don't think that's it. I walked the code several finding the loop on it self here: http://code.google.com/searchframe#T04cSGC7sWI/trunk/user/src/com/google/gwt/user/server/rpc/impl/SerializabilityUtil.java&q=SerializabilityUtil%20package:google-web-toolkit%5C.googlecode%5C.com&l=870

That indeed looks strange (I haven't looked closely at the code though).
I don't see anything strange or wrong here.
 
I don't have the *_CustomFieldSerializer in the translatable path either

That's a mistake: the *_CustomFieldSerializer is used both on client and server side.

Thomas Broyer

unread,
Jan 6, 2013, 7:30:32 AM1/6/13
to google-we...@googlegroups.com


On Wednesday, January 2, 2013 6:39:47 PM UTC+1, Thomas Broyer wrote:


On Wednesday, January 2, 2013 6:16:36 PM UTC+1, Brandon Donnelson wrote:
Good point, but I don't think that's it. I walked the code several finding the loop on it self here: http://code.google.com/searchframe#T04cSGC7sWI/trunk/user/src/com/google/gwt/user/server/rpc/impl/SerializabilityUtil.java&q=SerializabilityUtil%20package:google-web-toolkit%5C.googlecode%5C.com&l=870

That indeed looks strange (I haven't looked closely at the code though).

I looked a bit more at it and there's actually nothing that strange here. One could say the code could be better optimized but that's it.
This method is used to generate a "signature" for a type that will change whenever its serialization changes. When a type has no CustomFieldSerializer, its fields are used; otherwise, because we cannot tell which fields will be serialized, the signature for the type is the signature for its CustomFieldSerializer. That's the reason for the recursive call. It's not expected then that the CustomFieldSerializer itself has a CustomFieldSerializer. If you want to make it better, then add a boolean argument to the method to tell whether a CustomFieldSerializer should be used or not (or maybe split the method in two), so that when computing the signature for the CustomFieldSerializer we don't look for the CustomFieldSerializer's CustomFieldSerializer.

Brandon Donnelson

unread,
Jan 7, 2013, 5:22:06 PM1/7/13
to google-we...@googlegroups.com
Sounds good. Once I saw where the white list .gwt.rpc was getting built this made more sense. Its probably splitting hairs optimizing for that recursion :)
Reply all
Reply to author
Forward
0 new messages