This is originally reported from
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=93750 where an accidental
serialization of CachedMapImpl has occurred.
Brian has also created
http://jira.jboss.com/jira/browse/JBCACHE-830.
I have raised it here for further discussion.
I need to document it more clearly. However, the Collection proxy are not meant for
serialization since the proxy won't come out properly once it is serialized (the
interceptor reference is local only). The proper way to serialize a Collection (outside of
the PojoCache) is to use the detach call first, e.g.,
List list = new ArrayList();
...
cache.attach("list", list);
list = cache.find("list"); // This is a proxy
...
list = cache.detach("list"); // now this returns a normal List and can be
serialized properly.
So looks like we have two choices:
1. Throw an exception when VM tries to serialize it?
2. Make all the fields transient if there is really a use case for that.
Of course, if you make every POJO "aspectized" then this won't be an issue
since replication won't involved the proxy itself (rather just the fields). This
occurs when a POJO contains a object graph that has this reference.
Like I said, I will document this further. But do we really see a use case that
inenvitably we need to serialize the proxy?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3982840#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...