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

Bug 333242

Summary: Double checked locking in WorkbenchErrorHandler
Product: [Eclipse Project] Platform Reporter: Ralf Sternberg <rsternberg>
Component: UIAssignee: Platform-UI-Inbox <Platform-UI-Inbox>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: krzysztof.daniel, remy.suen
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Ralf Sternberg CLA 2010-12-27 09:20:29 EST
The fix for bug 218137 introduced double checked locking in WorkbenchErrorHandler#getStatusDialogManager().
This pattern is considered broken because this can return partially constructed objects to clients.
See http://en.wikipedia.org/wiki/Double-checked_locking,
 http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html
Comment 1 Krzysztof Daniel CLA 2011-01-03 08:23:41 EST
The pattern is considered broken only for multithreaded apps.
WorkbenchErrorHandler#handle ensures that all private methods are called only from UI thread, therefore partial initialization of statusDialogManager field will not happen.

Feel free to reopen if I am wrong.
Comment 2 Ralf Sternberg CLA 2011-01-03 18:59:42 EST
(In reply to comment #1)
> The pattern is considered broken only for multithreaded apps.
> WorkbenchErrorHandler#handle ensures that all private methods are called only
> from UI thread, therefore partial initialization of statusDialogManager field
> will not happen.
> 
> Feel free to reopen if I am wrong.

Oh, I was not aware that this method is only called from the UIThread.

But then, just out of curiosity: what's the use of this synchronized block at all given that the private field statusDialogManager is only accessed from this very method and therefore only from the UIThread?