GWT RPC Serialization - circular references not allowed?

2011-02-17 Thread Karthik Abram
I'm serializing to the client from Java using the standard GWT RPC
mechanism (using Async Service, not the factory introduced in 2.1).
I'm seeing an issue with deserialization at the client when my
serialized object has circular references. This is what I see:

Serializing a Result object that has a Fund object reference. This
fund has a reference to a Distributor object that contains a list of
Funds, one of which is the same as the Fund that result references. So
it is a two-hop circular reference.

The Fund object's hashCode method is overridden to use the fund-id's
hashcode (fund-id is a string). The error I get is that the hashcode
threw a NullPointerException.

Here is the stacktrace:
at com.foo.dm.fund.Fund.hashCode(Fund.java:709)
at java.util.HashMap.put(HashMap.java:372)
at java.util.HashSet.add(HashSet.java:200)
at 
com.google.gwt.user.client.rpc.core.java.util.Collection_CustomFieldSerializerBase.deserialize(Collection_CustomFieldSerializerBase.java:35)
at 
com.google.gwt.user.client.rpc.core.java.util.HashSet_CustomFieldSerializer.deserialize(HashSet_CustomFieldSerializer.java:32)
at 
com.google.gwt.user.client.rpc.core.java.util.HashSet_FieldSerializer$Handler.deserialize(HashSet_FieldSerializer.java:11)
at 
com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBase.java:91)
at 
com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:108)
at 
com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
at 
com.foo.dm.user.Distributor_FieldSerializer.deserialize(Distributor_FieldSerializer.java:42)

Are circular references not allowed? I can't believe this is the first
time I'm running across this in 2 years!

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: GWT RPC Serialization - circular references not allowed?

2011-02-17 Thread kabram
This is using GWT 2.1.1 with JDK 1.6

On Feb 17, 1:14 pm, Karthik Abram karthik.ab...@gmail.com wrote:
 I'm serializing to the client from Java using the standard GWT RPC
 mechanism (using Async Service, not the factory introduced in 2.1).
 I'm seeing an issue with deserialization at the client when my
 serialized object has circular references. This is what I see:

 Serializing a Result object that has a Fund object reference. This
 fund has a reference to a Distributor object that contains a list of
 Funds, one of which is the same as the Fund that result references. So
 it is a two-hop circular reference.

 The Fund object's hashCode method is overridden to use the fund-id's
 hashcode (fund-id is a string). The error I get is that the hashcode
 threw a NullPointerException.

 Here is the stacktrace:
 at com.foo.dm.fund.Fund.hashCode(Fund.java:709)
         at java.util.HashMap.put(HashMap.java:372)
         at java.util.HashSet.add(HashSet.java:200)
         at 
 com.google.gwt.user.client.rpc.core.java.util.Collection_CustomFieldSeriali­zerBase.deserialize(Collection_CustomFieldSerializerBase.java:35)
         at 
 com.google.gwt.user.client.rpc.core.java.util.HashSet_CustomFieldSerializer­.deserialize(HashSet_CustomFieldSerializer.java:32)
         at 
 com.google.gwt.user.client.rpc.core.java.util.HashSet_FieldSerializer$Handl­er.deserialize(HashSet_FieldSerializer.java:11)
         at 
 com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBa­se.java:91)
         at 
 com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deseria­lize(ClientSerializationStreamReader.java:108)
         at 
 com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readO­bject(AbstractSerializationStreamReader.java:119)
         at 
 com.foo.dm.user.Distributor_FieldSerializer.deserialize(Distributor_FieldSe­rializer.java:42)

 Are circular references not allowed? I can't believe this is the first
 time I'm running across this in 2 years!

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: GWT RPC Serialization - circular references not allowed?

2011-02-17 Thread Paul Robinson

Circular references over RPC do generally work, but when it comes to hash maps 
and hash sets, it doesn't always work out-of-the-box.

See this issue for details, and a work-around:
http://code.google.com/p/google-web-toolkit/issues/detail?id=3577

Paul


On 17/02/11 18:14, Karthik Abram wrote:

I'm serializing to the client from Java using the standard GWT RPC
mechanism (using Async Service, not the factory introduced in 2.1).
I'm seeing an issue with deserialization at the client when my
serialized object has circular references. This is what I see:

Serializing a Result object that has a Fund object reference. This
fund has a reference to a Distributor object that contains a list of
Funds, one of which is the same as the Fund that result references. So
it is a two-hop circular reference.

The Fund object's hashCode method is overridden to use the fund-id's
hashcode (fund-id is a string). The error I get is that the hashcode
threw a NullPointerException.

Here is the stacktrace:
at com.foo.dm.fund.Fund.hashCode(Fund.java:709)
at java.util.HashMap.put(HashMap.java:372)
at java.util.HashSet.add(HashSet.java:200)
at 
com.google.gwt.user.client.rpc.core.java.util.Collection_CustomFieldSerializerBase.deserialize(Collection_CustomFieldSerializerBase.java:35)
at 
com.google.gwt.user.client.rpc.core.java.util.HashSet_CustomFieldSerializer.deserialize(HashSet_CustomFieldSerializer.java:32)
at 
com.google.gwt.user.client.rpc.core.java.util.HashSet_FieldSerializer$Handler.deserialize(HashSet_FieldSerializer.java:11)
at 
com.google.gwt.user.client.rpc.impl.SerializerBase.deserialize(SerializerBase.java:91)
at 
com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:108)
at 
com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
at 
com.foo.dm.user.Distributor_FieldSerializer.deserialize(Distributor_FieldSerializer.java:42)

Are circular references not allowed? I can't believe this is the first
time I'm running across this in 2 years!



--
You received this message because you are subscribed to the Google Groups Google 
Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.