On Sunday 05 December 2004 16:20, Scott Deboy wrote: > I haven't tried sending events from log4j 1.3 to log4j 1.2.8, but I doubt > deserialization would work, without more changes to serialization logic. > > In 1.3, LoggingEvent contains a new field: > long sequenceNumber > The 1.2.8 code wouldn't know what to do with it.
Being a somewhat expert on serialization, I can offer the expert insight you may require. For the above; Adding a field is, without further action, an incompatible serialization change, because it changes the signature of the class. However, if both classes have the same serialVerUID, it is a compatible change, i.e. the field will be ignored from the stream. Since the 1.2 classes already exists, and you want to remain comptible in 1.3, you will need to run the serialtool against the old class and put in the generated value in the 1.3 class. If there has been serialization incompatible changes with the 1.2.x line, you will only get compatibility with one of those, preferably the last one. This can be checked by running serialtool against each of the older versions, and see if the same number is generated. For NEW serializable classes, just put in a serialVerUID=1. That number only needs to be incremented/changed when there is a serialization incompatible change. Furthermore, it is recommended that you provide your own readObject and writeObject methods for each of the serializable classes to get better control of what is going and more easily handle the process. For instance, a missing field from 1.2 being deserialized in 1.3 will contain a field specific default value (0 for int, null for Objects), which may not be accurate. Cheers Niclas -- +------//-------------------+ / http://www.dpml.net / / http://niclas.hedhman.org / +------//-------------------+ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
