[PATCH EGIT] Fix NPE on missing git data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fix the following NPE:
!ENTRY org.eclipse.core.resources 4 2 2009-04-30 22:52:47.117
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.core.resources".
!STACK 0
java.lang.NullPointerException
    at org.spearce.egit.core.project.RepositoryMapping.getMapping(RepositoryMapping.java:235)
    at org.spearce.egit.ui.internal.decorators.GitLightweightDecorator$2.visit(GitLightweightDecorator.java:492)
    at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:68)
    at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:79)
    at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:79)
    at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:79)
    at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:79)
    at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:79)
    at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:55)
    at org.spearce.egit.ui.internal.decorators.GitLightweightDecorator.resourceChanged(GitLightweightDecorator.java:477)
    at org.eclipse.core.internal.events.NotificationManager$2.run(NotificationManager.java:288)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
    at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:282)
    at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:148)
    at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:313)
    at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:1022)
    at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:45)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Signed-off-by: Daniel Cheng (aka SDiZ) <git@xxxxxxxx>
---
 .../egit/core/project/RepositoryMapping.java       |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryMapping.java b/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryMapping.java
index b49f380..029c56a 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryMapping.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryMapping.java
@@ -232,6 +232,9 @@ public static RepositoryMapping getMapping(final IResource resource) {
 		if (!(rp instanceof GitProvider))
 			return null;
 
+		if (((GitProvider)rp).getData() == null)
+			return null;
+
 		return ((GitProvider)rp).getData().getRepositoryMapping(resource);
 	}
 
-- 
1.6.2.1

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]