Issue Details (XML | Word | Printable)

Key: CASTOR-1152
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Andrew Fawcett
Reporter: David Green
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
castor

SourceGenerator: PropertyChangeListeners for bound properties should not be serialized

Created: 08/Jun/05 04:24 PM   Updated: 30/Nov/05 03:51 PM
Component/s: XML code generator
Affects Version/s: 0.9.9
Fix Version/s: 0.9.9.1

Time Tracking:
Not Specified

File Attachments: 1. Zip Archive bug1152.zip (1 kB)
2. Text File Castor1152-configurable.patch (6 kB)
3. Text File ctfrun_out.txt (218 kB)
4. Text File ctfrun_out2.txt (179 kB)
5. Text File SourceFactory.java.patch (2 kB)
6. Text File SourceFactory_PropertyChangeSupport.java.patch (5 kB)



 Description  « Hide
SourceGenerator generates propertyChangeListeners Vector for JavaBeans generated from XSD. This member should be transient so that change listeners are not serialized/deserialized.

Patch (against CVS HEAD) to SourceFactory.java included.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
David Green added a comment - 08/Jun/05 05:16 PM
A CTF test case.
It's not clear how to make JUnit check for a transient keyword in the test case.

David Green added a comment - 03/Aug/05 03:58 PM
How can I find out if there is any activity or interest in this issue? What else can I do to get the patch applied?

Werner Guttmann added a comment - 04/Aug/05 02:06 AM
David, I know it can be frustrating to not get any feedback upfront. If I were you, I'd send an email to the dev mailing list asking for feedback on the validity of the approach, and inquire whether somebody can take ownership of this issue. If, in the meantime, you could try to run the CTF suite and see whether everything still runs fine, you'd definitely decreease somebody else's workload.

David Green added a comment - 04/Aug/05 10:18 AM
CTF test suite run output.

David Green added a comment - 04/Aug/05 10:18 AM
CTF test suite run output file (CTF run without patch)

David Green added a comment - 04/Aug/05 10:20 AM
I've run the CTF suite against CVS HEAD with and without the patch, and attached the output of the CTF suite. (ctfrun_out.txt is output without patch, ctfrun_out2.txt is output with patch). The patch doesn't break any CTF tests.

Werner Guttmann added a comment - 04/Aug/05 10:51 AM
Just following up with regards to your email to the dev mailing list. I really don't believe that the listeners should be serialized at all, but in order not to break that behaviour, making this configurable per castor.properties sounds about right to me.

David Green added a comment - 04/Aug/05 11:26 AM
Attached a patch that permits configuration of this feature (on/off) via the standard properties file with the default setting being equivalent to pre-patch behaviour.

Gregory Block added a comment - 04/Aug/05 03:21 PM
Totally disagree.

1) PropertyChangeListener interface is not serializable.
2) The beans API knows this, and expects you to use PropertyChangeSupport to implement the listeners; you then serialize the PropertyChangeSupport object.
3) You then hook up your API to the PropertyChangeSupport API via delegation, which then correctly handles proxies and does the work of allowing serialization to happen on the list of listeners, only some of which might be serializable.

Either move to PropertyChangeSupport in all generated objects, or make darn sure we never serialize by marking it transient.


Gregory Block added a comment - 04/Aug/05 03:22 PM
And by all means, break current and historical behavior.

David Green added a comment - 04/Aug/05 04:03 PM
Good point: using PropertyChangeSupport would permit runtime choice of listeners participating in serialization.

Werner Guttmann added a comment - 05/Aug/05 02:27 AM
Alright, not knowing a lot about PropertyChangeListeners et alias, what does this translate to ? It looks like the configuration mechanism via castor.properties is not required.

Gregory Block added a comment - 08/Aug/05 05:04 AM
Correct - no configuration mechanism, as it shouldn't exist.

Basically, the purpose of using PropertyChangeSupport is twofold: Add support for proxied listeners, and properly support serialization.

If you don't use the PropertyChangeSupport methods, you have to code it all yourself; moreover, because you've got a raw list, you then also have to code your own manual serialization/deserialiation methods - something which this just can't do.

PropertyChangeSupport implements all the required methods for serializing and deserializing safely; it also implements all the helper methods needed, in a way that supports proxyied listeners..

Please move to a PCS-based implementation to eliminate this and other problems, as that's the intended implementation of PropertyChangeListener support in beans objects.

As for what this is for? I have no idea. I never use sourcegen.


David Green added a comment - 22/Aug/05 12:14 PM
PropertyChangeSupport does indeed appear to be the least intrusive approach, and does follow the serialization behaviour as intended by the Java standard. This patch causes the source generator to generate JavaBeans with java.beans.PropertyChangeSupport instead of Vector.

Andrew Fawcett added a comment - 10/Oct/05 08:39 AM
Small change to submitted patch to retain existing signature of the removePropertyChangeListner method.