Bug 235305 - [api] SystemPostableEventNotifier works synchronous contrary to documentation
Summary: [api] SystemPostableEventNotifier works synchronous contrary to documentation
Status: ASSIGNED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: Future   Edit
Assignee: dsdp.tm.rse-inbox CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords: api
Depends on: 190231
Blocks:
  Show dependency tree
 
Reported: 2008-06-03 07:21 EDT by Martin Oberhuber CLA
Modified: 2012-11-19 04:57 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Oberhuber CLA 2008-06-03 07:21:04 EDT
During code review for bug 227750, I found that SystemPostableEventNotifier is currently implemented to run a 

   Display.syncExec()

which is totally against API Javadoc, which claims that this class posts events asynchronously. The code has been a syncExec ever since the initial population in the openRSE repository, even before our refactorings. Only bug 150919 has been applied to that class so far.

The code is currently only used from 
    SystemResourceChangeManager#postNotify()
which is only called from 
    SystemRegistryUI.postEvent(ISystemResourceChangeEvent)
which is only called from 
    DaytimeSubSystem#initializeSubSystem()
where it's already wrapped in a Display.asyncExec() call.

I think we should do the following:
(1) Change DaytimeSubSystem to avoid the call since it's unnecessary.
(2a) Consider removing SystemRegistryUI.postEvent() as well as 
     SystemPostableEventNotifier -- what do committers think?
(2b) As an alternative, fix the implementation to dow what's described
(2c) Or, fix the API Javadocs to describe what's currently done

In case we are not removing the API calls, I think the description and implementation should be changed to make use of the new IRSEInteractionProvider#asyncExec() logic in order to avoid unnecessary UI
dependency.

-----------Enter bugs above this line-----------
TM 3.0RC2 testing
installation : eclipse-SDK-3.4RC3 (I20080530-1730), cdt-5.0RC2 (200805231539), 
     DSF-1.0rc2 (20080527), emf-2.4.0rc2, Findbugs-1.3.3, Releng.Tools-3.4RC3, 
     RSE-3.0RC2, RXTX-2.1-7r3b, Subversive-0.7.0.v20080517, FTP_WebDav-3.2.2
     org.tigris.MemMonitor, WR-Retriever-3.0.v20070604,
RSE install  : RSE 3.0RC2 in workspace, TM-terminal, TM-discovery
java.runtime : Sun 1.6.0_05-b13 -Xmx512m -XX:MaxPermSize=128m
os.name:     : Windows XP 5.1, Service Pack 2
------------------------------------------------
systemtype   : Windows-local, Dstore-win, Dstore-linux
targetos     : Red Hat Enterprise Linux WS release 4 (Nahant Update 3)
targetuname  : Linux parser 2.6.9-34.EL #1 i686 athlon i386 GNU/Linux
targetvm     : Sun Java HotSpot(TM) Client VM (build 1.4.2_12-b03, mixed mode)
------------------------------------------------
Comment 1 David Dykstal CLA 2008-06-03 07:26:45 EDT
I vote for (1) and (2a) unless we can find other product uses of this that would preclude its removal. If that were to happen I'd vote for (2c).
Comment 2 Xuan Chen CLA 2008-06-03 08:00:10 EDT
Does not seems we are affected (so far).

I agreed with Dave D.

Thanks.
Comment 3 Martin Oberhuber CLA 2008-06-03 08:19:25 EDT
Here is some more data:

* Javadoc in ISystemRegistryUI#postEvent() explicitly says that 
  Display.asyncExec() is used to post events into the Display thread. This doc
  has been in there since openRSE - initial (SystemRegistry v1.1).

* The implementation, however, looks like it always used 
  SystemPostableEventNotifier which did the syncExec() -- incorrectly, in my
  opinion.

* There are additional callers of this through 
     SystemRegistryUI#postEvent(ISystemResourceChangeListener, ISRCEvent)
  which I did not find in my first search. The callers are 3, all of which
  are in rse.internal.ui.view so they can be changed to use Display.asyncExec()
  themselves if needed:
     SystemViewAPIProviderForFilters
     SystemViewFilterAdapter
     SystemViewFilterReferenceAdapter

* In SystemRegistry itself, we have the various fireEvent() variants. These
  used to be totally synchronous until 24-May-2007 (approx RSE 2.0RC1), when
  behavior was changed with bug 176601 to always fire events on the main Thread.
  Since then, the various fireEvent() variants work like this:
     * If already on main thread, fire event immediately and synchronously
     * If not on main thread, perform Display.asyncExec()
  I find this behavior slightly problematic because it's not clear for the 
  caller whether the event will eventually be executed synchronously or 
  asynchronously. I will do more investigations of this, because it's 
  important to know our whole event posting story such that we can write
  migration docs and guidance in case we remove the postEvent() variants.

My general feeling is, that migration notes should instruct users to run
RSECorePlugin.getInteractionProvider().asyncExec() instead of the 
SystemPostableEventNotifier, in case we get rid of that class.
Comment 4 Martin Oberhuber CLA 2008-08-19 11:09:57 EDT
Likely won't be able to change behavior in 3.1 but look at the documentation again when the IRSEInteractionProvider is actually implemented as per bug 190231.