Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Baumgart2010-09-10 13:04:45 +0000
committerMatthias Sohn2010-09-18 21:38:24 +0000
commit4c487c493ab3c6c0e8178a51b484b47229844a14 (patch)
tree92e217d4bb24325a91034c57fe40feaac6c81997
parent6c8423aee1978e6909b2179d5e5a08794325cd5a (diff)
downloadegit-4c487c493ab3c6c0e8178a51b484b47229844a14.tar.gz
egit-4c487c493ab3c6c0e8178a51b484b47229844a14.tar.xz
egit-4c487c493ab3c6c0e8178a51b484b47229844a14.zip
Fix NPE in decorator
NPE can occur if the file to be decorated is deleted while decoration is running. Change-Id: I54cb9f52097bcf486b72c9dd5cdb9452af297e9b Signed-off-by: Jens Baumgart <jens.baumgart@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceAdapter.java7
2 files changed, 10 insertions, 3 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java
index b131e2cfb8..c0c0b200d2 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java
@@ -178,10 +178,14 @@ public class RepositoryMapping {
*
* @param rsrc
* @return the path relative to the Git repository, including base name.
+ * <code>null</code> if the path cannot be determined.
*/
public String getRepoRelativePath(final IResource rsrc) {
final int pfxLen = workdirPrefix.length();
- final String p = rsrc.getLocation().toString();
+ IPath location = rsrc.getLocation();
+ if (location == null)
+ return null;
+ final String p = location.toString();
final int pLen = p.length();
if (pLen > pfxLen)
return p.substring(pfxLen);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceAdapter.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceAdapter.java
index b36f8bc670..d27a9b2fd8 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceAdapter.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceAdapter.java
@@ -392,8 +392,11 @@ class DecoratableResourceAdapter implements IDecoratableResource {
*/
private boolean addResourceFilter(final TreeWalk treeWalk,
final IResource resourceToFilterBy) {
- Set<String> repositoryPaths = Collections.singleton(mapping
- .getRepoRelativePath(resourceToFilterBy));
+ String repoRelativePath = mapping
+ .getRepoRelativePath(resourceToFilterBy);
+ if (repoRelativePath==null)
+ return false;
+ Set<String> repositoryPaths = Collections.singleton(repoRelativePath);
if (repositoryPaths.isEmpty())
return false;

Back to the top