Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 357615

Summary: EventManager should be serializable
Product: [Eclipse Project] Platform Reporter: Rüdiger Herrmann <ruediger.herrmann>
Component: RuntimeAssignee: platform-runtime-inbox <platform-runtime-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: fwaibel, ob1.eclipse, pwebster, ruediger.herrmann, tjwatson
Version: 3.7.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 486067    
Bug Blocks: 352926    
Attachments:
Description Flags
Patch to make ListenerList serializable
none
Patch to make EventManager serializable none

Description Rüdiger Herrmann CLA 2011-09-14 06:46:13 EDT
Currently, classes derived from EventManager in org.eclipse.core.commands.common cannot be fully serialized because the EventManagers listenerList field is marked as transient.

The RAP project maintains a 'fork' of JFace with with changes to make JFace run in a multi-user web environment. We are in the process of enabling transparent session-failover in RAP. To achieve this, all objects that 'live' in a session must be serializable so that a servlet container can persist the current state of a session. This applies to most classes from JFace, where in turn many of them inherit from EventManager, e.g. BaseLabelProvider.
Therefore I suggest to make the private listenerList field of EventManager non-transient and change the ListenerList from org.eclipse.core.runtime to implement Serializable.
With these changes, the BaseLabelProvider from the JFace/RAP bundle could be changed to implement Serializable and then be used in environments that require session-failover.

I will provide a patch with the necessary changes and tests if it is agreed on that the proposed changes should be made.
Comment 1 Thomas Watson CLA 2011-09-14 10:31:00 EDT
org.eclipse.core.commands is in the Platform->UI git repo.
Comment 2 Paul Webster CLA 2011-09-15 14:48:20 EDT
It would start with ListenerList (core.runtime) being serializable ... but the events that this class stores aren't guaranteed to be seralizable, they're just any old Object, no?

PW
Comment 3 Rüdiger Herrmann CLA 2011-09-16 04:03:10 EDT
(In reply to comment #2)
> It would start with ListenerList (core.runtime) being serializable ... but the
> events that this class stores aren't guaranteed to be seralizable, they're just
> any old Object, no?
Right, the objects that this class stores aren't necessarily serializable. But as ListenerList is mainly used as a utility class instead of directly being exposed, the calling code can ensure that only serializable objects are stored. Like Viewer.addSelectionChangedListener() makes sure that only ISelectionChangedListeners are stored.
Comment 4 Rüdiger Herrmann CLA 2011-09-19 10:31:12 EDT
Created attachment 203597 [details]
Patch to make ListenerList serializable

This change makes org.eclipse.core.runtime.ListenerList in bundle org.eclipse.equinox.common serializable
Comment 5 Rüdiger Herrmann CLA 2011-09-19 10:48:21 EDT
Created attachment 203601 [details]
Patch to make EventManager serializable

The EventManager was made serializable. 
The current compiler setting is to handle serializable classes without a serialVersionUID as an error. To avoid touching all classes that inherit from EventManager, I changed the problem severity to 'ignore' for now. How would you like this case to be handled? Should I declare serialVersionUID for all affected classes?