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

Bug 333787

Summary: [event] bad EventHandler with LogEntry topic can cause endless event dispatching
Product: [Eclipse Project] Equinox Reporter: Thomas Watson <tjwatson>
Component: CompendiumAssignee: Thomas Watson <tjwatson>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.7   
Target Milestone: 3.7 M5   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
possible fix
none
possible fix
none
proposed fix none

Description Thomas Watson CLA 2011-01-07 16:38:48 EST
If a LogService is present and a bad EventHandler listens for the org/osgi/service/log/LogEntry/* topic then endless event dispatching can occur if the EventHandler continually throws runtime exceptions.

The event admin implementation should probably try to handle this.
Comment 1 Thomas Watson CLA 2011-01-07 16:45:39 EST
Created attachment 186317 [details]
possible fix

This fix will detect a possible endless LogEntry event posting by wrapping the EventHanders exception in a special exception when the event topic starts with "org/osgi/service/log/LogEntry".  This way we can detect a second exception from a handler if the log call causes another exception from an EventHandler.
Comment 2 Thomas Watson CLA 2011-01-07 17:21:38 EST
Created attachment 186319 [details]
possible fix

The previous patch prevented endless events but had a bug.  It tried to cast the event property "exception" to Class which would cause a cast exception.  The property "exception" is not a Class but the actual exception.  This patch fixes that.
Comment 3 Thomas Watson CLA 2011-01-07 17:33:17 EST
Created attachment 186321 [details]
proposed fix

OK, lets try this again.  Same idea but with a simple instanceof check.
Comment 4 Thomas Watson CLA 2011-01-07 21:20:42 EST
patch released.