Hi Andrus

2012/3/5 Andrus Adamchik <[email protected]>

> You might be right indeed. Cayenne serialization behavior was implemented
> based on the description from java.io.Serializable javadocs, which does not
> mention a call to 'defaultWriteObject' as required. So it is skipped...
> Sure enough that has never caused us any problems with the JDK (there's
> lots of serialization tests in our unit test suite).
>

Yeah, I ended up building my own version of River commenting out just the
lines (in RiverObjectOutputStream and RiverObjectInputStream) where the
exception is thrown and it works just fine.


>
> But of course alternative serialization solutions are free to complain
> about this behavior, and that seems to be the case with River marshaller.
>

Yes, that is the case, and I'm not sure what is the correct way to do this.
I'm leaning more and more towards that River is way too strict on this.
There is probably a reason this is only in the spec and not strictly
enforced anywhere else.
The spec says: "the behavior of instance deserialization is undefined in
cases where the ObjectInputStream cannot resolve the class which defined
the writeObject method". I don't know which cases those are, but this is
not one of them. It works fine in Cayenne when I disable the exceptions. As
you said, the Serializable javadoc says that you CAN invoke
defaultWriteObject, not that you must. This is all very vague and I'm not
sure the interpretation used by River is correct.
I've not been able to find any other libraries where this is a problem so
I'm thinking that this is actually more of a River problem, even though it
might be technically correct. One thing to consider is that River is doing
marshalling, which apparently is slightly different from serialization, but
the actual difference is not clear to me. I don't know if that is important.


>
> Appreciate if you can open a bug report in Cayenne Jira. I think we can
> fix it...
>

I can do that, but I'm not yet sure that it is a Cayenne problem. Cayenne
tries to serialize only the ObjectId if possible, and by calling
defaultWriteObject wouldn't you lose that functionality? Wouldn't it then
serialize all the fields every time? I don't think we want that. Or did you
have another solution in mind?


-Erlend

Reply via email to