Bug: Serialisation breaks with multiple references to same object

2 views
Skip to first unread message

georgeuoa

unread,
Jun 27, 2006, 7:49:52 AM6/27/06
to Google Web Toolkit
When you have an object referenced from both an ArrayList and a normal
reference from another object, deserialising (on the server side)
breaks with an exception [1].


abstract class Operator{
....
}

class OperatorA extends Operator{
...
}

class OperatorB extends Operator{
...
}

class OperatorC extends Operator{
...
}

class Column{

private List applicableOperators = new ArrayList(); // + getters &
setters
private Operator; // + getters & setters
}

On the server side:

Column column = new Column();
column.getApplicableOperators().add(new OperatorA());
column.getApplicableOperators().add(new OperatorB());
column.getApplicableOperators().add(new OperatorC());

Now, on the client side you do (in response to a click event for
example) a:

Operator operator = column.getApplicableOperators().get(1);
column.setOperator(operator);

When you send this back to the server, it failes with the exception
[1].

_however_, if you do a
Operator operator = column.getApplicableOperators().remove(1);
column.setOperator(operator);

then it works just fine, which leads me to the assumption that there is
an issue with shared references.

G.
-------------------------------------------
Celebrating the 4th bug report

[1]
<pre>
Caused by: java.lang.IllegalArgumentException
at
sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
at java.lang.reflect.Field.set(Field.java:656)
at
com.google.gwt.user.server.rpc.ServerSerializationStream.deserializeClass(ServerSerializationStream.java:470)
at
com.google.gwt.user.server.rpc.ServerSerializationStream.deserialize(ServerSerializationStream.java:519)
at
com.google.gwt.user.server.rpc.ServerSerializationStream.readObject(ServerSerializationStream.java:443)
at
com.google.gwt.user.client.rpc.core.java.util.ArrayList_CustomFieldSerializer.deserialize(ArrayList_CustomFieldSerializer.java:49)
...
</pre>

Reply all
Reply to author
Forward
0 new messages