Bug 125560 [Viewers] Invalid thread access on tree viewer results in NPE
I peformed an update to a tree viewer from a non-UI thread which resulted in an Invalid Thread Access error as one would expect. However, the viewer tried to prompt for the error which resulted in an NPE since the prompt was being attempted from a non-UI thread (or, at least, I assume that's why the display variable was null). Hre's the trace: java.lang.NullPointerException at org.eclipse.jface.dialogs.IconAndMessageDialog.getSWTImage(IconAndMessageDialog.java:265) at org.eclipse.jface.dialogs.IconAndMessageDialog.getErrorImage(IconAndMessageDialog.java:212) at org.eclipse.jface.dialogs.MessageDialog.<init>(MessageDialog.java:141) at org.eclipse.jface.dialogs.MessageDialog.openError(MessageDialog.java:310) at org.eclipse.jface.util.SafeRunnable.handleException(SafeRunnable.java:59) at org.eclipse.core.runtime.SafeRunner.handleException(SafeRunner.java:65) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:39) at org.eclipse.core.runtime.Platform.run(Platform.java:785) at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:148) at org.eclipse.jface.viewers.StructuredViewer.updateItem(StructuredViewer.java:1859) at org.eclipse.jface.viewers.StructuredViewer.internalUpdate(StructuredViewer.java:1842) at org.eclipse.jface.viewers.StructuredViewer.update(StructuredViewer.java:1792) at org.eclipse.jface.viewers.StructuredViewer.update(StructuredViewer.java:1747) at org.eclipse.team.internal.ui.mapping.ResourceTeamAwareContentProvider.propertyChanged(ResourceTeamAwareContentProvider.java:233) at org.eclipse.team.core.diff.provider.DiffTree$1.run(DiffTree.java:254) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.core.runtime.Platform.run(Platform.java:785) at org.eclipse.team.core.diff.provider.DiffTree.fireChanges(DiffTree.java:242) at org.eclipse.team.core.diff.provider.DiffTree.endInput(DiffTree.java:220) at org.eclipse.team.internal.core.subscribers.SubscriberDiffTreeEventHandler.dispatchEvents(SubscriberDiffTreeEventHandler.java:162) at org.eclipse.team.internal.core.subscribers.SubscriberEventHandler.doDispatchEvents(SubscriberEventHandler.java:390) at org.eclipse.team.internal.core.BackgroundEventHandler.dispatchEvents(BackgroundEventHandler.java:354) at org.eclipse.team.internal.core.BackgroundEventHandler.processEvents(BackgroundEventHandler.java:334) at org.eclipse.team.internal.core.BackgroundEventHandler$1.run(BackgroundEventHandler.java:173) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
bundles/org.eclipse.jface/src/org/eclipse/jface/util/SafeRunnable.java
/*******************************************************************************
 * Copyright (c) 2000, 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     Chris Gross (schtoo@schtoo.com) - support for ISafeRunnableRunner added
 *       (bug 49497 [RCP] JFace dependency on org.eclipse.core.runtime enlarges standalone JFace applications)
 *******************************************************************************/
package org.eclipse.jface.util;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
/**
 * Implements a default implementation of ISafeRunnable. The default
 * implementation of <code>handleException</code> opens a message dialog.
 * <p>
 * <b>Note:<b> This class can open an error dialog and should not be used
 * outside of the UI Thread.
 * </p>
 */
public abstract class SafeRunnable implements ISafeRunnable {