Buggy code:
public final class Workbench implements IWorkbench { private static final String LEFT_TO_RIGHT = "ltr" ; private static final String RIGHT_TO_LEFT = "rtl" ; private static final String ORIENTATION_COMMAND_LINE = "-dir" ; private static final String ORIENTATION_PROPERTY = "eclipse.orientation" ; private static final String NL_USER_PROPERTY = "osgi.nl.user" ; private static final String [ ] VERSION_STRING = new String [ ] { "0.046" , "2.0" } ; private static final String DEFAULT_WORKBENCH_STATE_FILENAME = "workbench.xml" ; private static Workbench instance ; private static WorkbenchTestable testableObject ; private Display display ; private WindowManager windowManager ; private WorkbenchWindow activatedWindow ; private EditorHistory editorHistory ; private boolean runEventLoop = true ; private boolean isStarting = true ; private boolean isClosing = false ; private int returnCode = PlatformUI . RETURN_UNSTARTABLE ; private ListenerList windowListeners = new ListenerList ( ) ; private WorkbenchAdvisor advisor ; private WorkbenchConfigurer workbenchConfigurer ; private ExtensionEventHandler extensionEventHandler ; private int largeUpdates = 0 ; private Workbench ( Display display , WorkbenchAdvisor advisor ) { } public static final Workbench getInstance ( ) { } public static final int createAndRunWorkbench ( Display display , WorkbenchAdvisor advisor ) { } public static Display createDisplay ( ) { } public static WorkbenchTestable getWorkbenchTestable ( ) { } public void addWindowListener ( IWindowListener l ) { } public void removeWindowListener ( IWindowListener l ) { } protected void fireWindowOpened ( final IWorkbenchWindow window ) { } protected void fireWindowClosed ( final IWorkbenchWindow window ) { } protected void fireWindowActivated ( final IWorkbenchWindow window ) { } protected void fireWindowDeactivated ( final IWorkbenchWindow window ) { } private boolean busyClose ( final boolean force ) { } public boolean saveAllEditors ( boolean confirm ) { final boolean finalConfirm = confirm ; final boolean [ ] result = new boolean [ 1 ] ; result [ 0 ] = true ; Platform . run ( new SafeRunnable ( WorkbenchMessages . getString ( "ErrorClosing" ) ) { public void run ( ) { ArrayList dirtyEditors = new ArrayList ( ) ; ArrayList dirtyEditorsInput = new ArrayList ( ) ; IWorkbenchWindow [ ] windows = getWorkbenchWindows ( ) ; for ( int i = 0 ; i < ( windows . length ) ; i ++ ) { IWorkbenchPage [ ] pages = windows [ i ] . getPages ( ) ; for ( int j = 0 ; j < ( pages . length ) ; j ++ ) { WorkbenchPage page = ( ( WorkbenchPage ) ( pages [ j ] ) ) ; IEditorPart [ ] editors = page . getDirtyEditors ( ) ; for ( int k = 0 ; k < ( editors . length ) ; k ++ ) { IEditorPart editor = editors [ k ] ; <START_BUG> if ( editor . isDirty ( ) ) { <END_BUG> if ( ! ( dirtyEditorsInput . contains ( editor . getEditorInput ( ) ) ) ) { dirtyEditors . add ( editor ) ; dirtyEditorsInput . add ( editor . getEditorInput ( ) ) ; } } } } } if ( ( dirtyEditors . size ( ) ) > 0 ) { IWorkbenchWindow w = getActiveWorkbenchWindow ( ) ; if ( w == null ) w = windows [ 0 ] ; result [ 0 ] = EditorManager . saveAll ( dirtyEditors , finalConfirm , w ) ; } } } ) ; return result [ 0 ] ; } private IWorkbenchWindow busyOpenWorkbenchWindow ( String perspID , IAdaptable input ) throws WorkbenchException { } public boolean close ( ) { } boolean close ( int returnCode , final boolean force ) { } public IWorkbenchWindow getActiveWorkbenchWindow ( ) { } protected EditorHistory getEditorHistory ( ) { } public IEditorRegistry getEditorRegistry ( ) { } private int getNewWindowNumber ( ) { } public IWorkbenchOperationSupport getOperationSupport ( ) { } public IPerspectiveRegistry getPerspectiveRegistry ( ) { } public PreferenceManager getPreferenceManager ( ) { } public IPreferenceStore getPreferenceStore ( ) { } public ISharedImages getSharedImages ( ) { } WindowManager getWindowManager ( ) { } private File getWorkbenchStateFile ( ) { } public int getWorkbenchWindowCount ( ) { } public IWorkbenchWindow [ ] getWorkbenchWindows ( ) { } public IWorkingSetManager getWorkingSetManager ( ) { } public ILocalWorkingSetManager createLocalWorkingSetManager ( ) { } private boolean init ( Display display ) { } private int getDefaultOrientation ( String [ ] commandLineArgs ) { } private int checkCommandLineLocale ( ) { } private int getSystemPropertyOrientation ( ) { } private int getCommandLineOrientation ( String [ ] commandLineArgs ) { } private void initializeCommandResolver ( ) { } private void initializeApplicationColors ( ) { } private void initializeSingleClickOption ( ) { } private void initializeFonts ( ) { } private void initializeImages ( ) { } private void uninitializeImages ( ) { } private void initializeColors ( ) { } public boolean isClosing ( ) { } boolean isStarting ( ) { } private WorkbenchWindow newWorkbenchWindow ( ) { } private void forceOpenPerspective ( ) { } void openFirstTimeWindow ( ) { } IStatus restoreState ( ) { } public IWorkbenchWindow openWorkbenchWindow ( IAdaptable input ) throws WorkbenchException { } public IWorkbenchWindow openWorkbenchWindow ( final String perspID , final IAdaptable input ) throws WorkbenchException { } private XMLMemento recordWorkbenchState ( ) { } public boolean restart ( ) { } private IStatus restoreState ( IMemento memento ) { } public String [ ] getEarlyActivatedPlugins ( ) { } private void startPlugins ( ) { } private int runUI ( ) { } private void runEventLoop ( Window . IExceptionHandler handler , Display display ) { } private IStatus saveState ( IMemento memento ) { } private boolean saveMementoToFile ( XMLMemento memento ) { } public IWorkbenchPage showPerspective ( String perspectiveId , IWorkbenchWindow window ) throws WorkbenchException { } public IWorkbenchPage showPerspective ( String perspectiveId , IWorkbenchWindow window , IAdaptable input ) throws WorkbenchException { } private void shutdown ( ) { } public IDecoratorManager getDecoratorManager ( ) { } private WorkbenchWindow getActivatedWindow ( ) { }

Fix:
if ( editor . isSaveOnCloseNeeded ( ) ) {