aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Thun2011-02-24 07:06:02 (EST)
committerPhilipp Thun2011-02-25 12:45:08 (EST)
commitf0cf09a66e8895dc0c7ac56a15d50d64194e4f0b (patch)
treef660ce3ac4afdbb08b120d9be0fda78d0e6a8ff0
parentaf995baba72d1ea74b71b9109fd0bbff79ca267b (diff)
downloadegit-f0cf09a66e8895dc0c7ac56a15d50d64194e4f0b.zip
egit-f0cf09a66e8895dc0c7ac56a15d50d64194e4f0b.tar.gz
egit-f0cf09a66e8895dc0c7ac56a15d50d64194e4f0b.tar.bz2
Improve exception handling during resource decorationrefs/changes/94/2594/3
In case a resource cannot be decorated, do not show/ log an error, but silently ignore this problem (and trace the information). Also keep track of 'not decoratable' resources and do not try to decorate them again. Catch all exceptions that occur during decoration and trace them. Do not show/ log them as errors - they are only confusing. Bug: 337116 Bug: 337671 Change-Id: Iae63ecf51b47073c9216762b3d2dee8c458dbb77 Signed-off-by: Philipp Thun <philipp.thun@sap.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitDecoratorJob.java15
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java116
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties3
4 files changed, 73 insertions, 67 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
index fbcfa55..1e0cf78 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
@@ -2942,12 +2942,6 @@ public class UIText extends NLS {
public static String GitBranchSynchronizeWizardPage_deselectAll;
/** */
- public static String GitLightweightDecorator_AsynchronousDecorationError;
-
- /** */
- public static String GitLightweightDecorator_ResourceError;
-
- /** */
public static String GitTraceConfigurationDialog_ApplyButton;
/** */
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitDecoratorJob.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitDecoratorJob.java
index 5cb108e..904525d 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitDecoratorJob.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitDecoratorJob.java
@@ -15,6 +15,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.egit.ui.internal.trace.GitTraceLocation;
/**
* Job decorating Git resources asynchronously
@@ -81,8 +82,18 @@ public class GitDecoratorJob extends Job {
elements = elementList.toArray(new Object[elementList.size()]);
elementList.clear();
}
- // Call GitLightweightDecorator to process the decoration requests
- GitLightweightDecorator.processDecoration(elements);
+ try {
+ // Call GitLightweightDecorator to process the decoration
+ // requests
+ GitLightweightDecorator.processDecoration(elements);
+ } catch (Exception e) {
+ // Exceptions can be caused by concurrent threads and thus
+ // should be ignored
+ if (GitTraceLocation.DECORATION.isActive())
+ GitTraceLocation.getTrace().trace(
+ GitTraceLocation.DECORATION.getLocation(),
+ "An error occurred during resource decoration", e); //$NON-NLS-1$
+ }
}
return Status.OK_STATUS;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java
index eef3678..f1d6820 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java
@@ -43,6 +43,7 @@ import org.eclipse.egit.ui.UIIcons;
import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.UIText;
import org.eclipse.egit.ui.internal.decorators.IDecoratableResource.Staged;
+import org.eclipse.egit.ui.internal.trace.GitTraceLocation;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
@@ -98,6 +99,9 @@ public class GitLightweightDecorator extends LabelProvider implements
private static final QualifiedName DECORATABLE_RESOURCE_KEY = new QualifiedName(
Activator.getPluginId(), "decoratableResource"); //$NON-NLS-1$
+ private static final QualifiedName NOT_DECORATABLE_KEY = new QualifiedName(
+ Activator.getPluginId(), "notDecoratable"); //$NON-NLS-1$
+
/**
* Bit-mask describing interesting changes for IResourceChangeListener
* events
@@ -216,23 +220,30 @@ public class GitLightweightDecorator extends LabelProvider implements
return;
try {
- final Long refreshed = (Long) resource
- .getSessionProperty(REFRESHED_KEY);
- if (refreshed != null) {
- // Stored decoratable resource is available
- final Long refresh = (Long) resource.getWorkspace().getRoot()
- .getSessionProperty(REFRESH_KEY);
- if (refresh == null
- || refresh.longValue() <= refreshed.longValue()) {
- // Stored decoratable resource is up-to-date
- final IDecoratableResource decoratableResource = (IDecoratableResource) resource
- .getSessionProperty(DECORATABLE_RESOURCE_KEY);
- if (decoratableResource != null) {
- // Use stored decoratable resource
- final DecorationHelper helper = new DecorationHelper(
- activator.getPreferenceStore());
- helper.decorate(decoration, decoratableResource);
- return;
+ final Boolean notDecoratable = (Boolean) resource
+ .getSessionProperty(NOT_DECORATABLE_KEY);
+ if (notDecoratable != null && notDecoratable.equals(Boolean.TRUE)) {
+ // Resource is not decoratable, do not try again
+ return;
+ } else {
+ final Long refreshed = (Long) resource
+ .getSessionProperty(REFRESHED_KEY);
+ if (refreshed != null) {
+ // Stored decoratable resource is available
+ final Long refresh = (Long) resource.getWorkspace()
+ .getRoot().getSessionProperty(REFRESH_KEY);
+ if (refresh == null
+ || refresh.longValue() <= refreshed.longValue()) {
+ // Stored decoratable resource is up-to-date
+ final IDecoratableResource decoratableResource = (IDecoratableResource) resource
+ .getSessionProperty(DECORATABLE_RESOURCE_KEY);
+ if (decoratableResource != null) {
+ // Use stored decoratable resource
+ final DecorationHelper helper = new DecorationHelper(
+ activator.getPreferenceStore());
+ helper.decorate(decoration, decoratableResource);
+ return;
+ }
}
}
}
@@ -267,21 +278,20 @@ public class GitLightweightDecorator extends LabelProvider implements
*
* @param elements
* the list of elements to be decorated
+ * @throws IOException
*/
- static void processDecoration(final Object[] elements) {
+ static void processDecoration(final Object[] elements) throws IOException {
final GitLightweightDecorator decorator = (GitLightweightDecorator) Activator
.getDefault().getWorkbench().getDecoratorManager()
.getBaseLabelProvider(DECORATOR_ID);
if (decorator != null)
decorator.prepareDecoration(elements);
else
- exceptions
- .handleException(new CoreException(
- Activator
- .createErrorStatus(UIText.GitLightweightDecorator_AsynchronousDecorationError)));
+ throw new RuntimeException(
+ "Could not retrieve GitLightweightDecorator"); //$NON-NLS-1$
}
- private void prepareDecoration(final Object[] elements) {
+ private void prepareDecoration(final Object[] elements) throws IOException {
if (elements == null)
return;
@@ -291,42 +301,36 @@ public class GitLightweightDecorator extends LabelProvider implements
resources[i] = getResource(elements[i]);
}
- try {
- // Calculate resource decorations
- IDecoratableResource[] decoratableResources = DecoratableResourceHelper
- .createDecoratableResources(resources);
-
- // Store decoration result in session property for each resource
- for (int i = 0; i < decoratableResources.length; i++) {
- try {
- if (decoratableResources[i] != null) {
- // Store decoratable resource in session
- resources[i].setSessionProperty(
- DECORATABLE_RESOURCE_KEY,
- decoratableResources[i]);
- // Set (new) 'refreshed' timestamp
- resources[i].setSessionProperty(REFRESHED_KEY,
- Long.valueOf(System.currentTimeMillis()));
- } else {
- if (resources[i] != null)
- handleException(
- resources[i],
- new CoreException(
- Activator
- .createErrorStatus(UIText.GitLightweightDecorator_ResourceError)));
+ // Calculate resource decorations
+ IDecoratableResource[] decoratableResources = DecoratableResourceHelper
+ .createDecoratableResources(resources);
+
+ // Store decoration result in session property for each resource
+ for (int i = 0; i < decoratableResources.length; i++) {
+ try {
+ if (decoratableResources[i] != null) {
+ // Store decoratable resource in session
+ resources[i].setSessionProperty(DECORATABLE_RESOURCE_KEY,
+ decoratableResources[i]);
+ // Set (new) 'refreshed' timestamp
+ resources[i].setSessionProperty(REFRESHED_KEY,
+ Long.valueOf(System.currentTimeMillis()));
+ } else {
+ if (resources[i] != null) {
+ // Set 'notDecoratable' session property
+ resources[i].setSessionProperty(NOT_DECORATABLE_KEY,
+ Boolean.TRUE);
+ if (GitTraceLocation.DECORATION.isActive())
+ GitTraceLocation
+ .getTrace()
+ .trace(GitTraceLocation.DECORATION
+ .getLocation(),
+ "Could not decorate resource: " + resources[i].getFullPath()); //$NON-NLS-1$
}
- } catch (CoreException e) {
- handleException(resources[i], e);
}
+ } catch (CoreException e) {
+ handleException(resources[i], e);
}
- } catch (IOException e) {
- exceptions
- .handleException(new CoreException(
- Activator
- .createErrorStatus(
- UIText.GitLightweightDecorator_AsynchronousDecorationError,
- e)));
- return;
}
// Re-trigger decoration process (in UI thread)
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
index 8a051f5..a90072c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
@@ -1035,9 +1035,6 @@ GitBranchSynchronizeWizardPage_branches=Branches
GitBranchSynchronizeWizardPage_selectAll=Select All
GitBranchSynchronizeWizardPage_deselectAll=Deselect All
-GitLightweightDecorator_AsynchronousDecorationError=Asynchronous decoration requests for Git resources could not be processed
-GitLightweightDecorator_ResourceError=Resource could not be decorated
-
GitTraceConfigurationDialog_ApplyButton=&Apply
GitTraceConfigurationDialog_DefaultButton=&Default
GitTraceConfigurationDialog_DialogTitle=Maintain the Git Trace Configuration