Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 333242 - Double checked locking in WorkbenchErrorHandler
Summary: Double checked locking in WorkbenchErrorHandler
Status: CLOSED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-27 09:20 EST by Ralf Sternberg CLA
Modified: 2011-01-03 18:59 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 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?