This can easily happen -- a pojo with a collection field gets put in the cache, and then
some user code hands a ref to the collection to some other object, that object gets
serialized (say as part of a response to a remote call); boom!
The case on the other forum post is a bit odd, as the serialization there is occuring due
to cache replication itself. That's kind of a bad practice; they should aspectize all
their classes. But I think we need to support the generic case where a Collection gotten
from the cache gets serialized.
But, I don't think there's any need at all to try to maintain any object
relationship or anything when the object is deserialized. So, this kind of thing should
work fine:
Example is CachedListImpl:
| private Object writeReplace() throws ObjectStreamException {
| ArrayList toSerialize = new ArrayList();
| toSerialize.addAll(this);
| return toSerialize;
| }
|
toSerialize is what gets serialized. When deserialized, it's a List, as expected. If
the user thought the deserialized list would somehow be the same object as something
stored in a PojoCache somewhere (where???), they're not thinking right.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3982846#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...