Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2016-04-09 19:41:39 -0400
committerMatthias Sohn2016-04-18 03:09:38 -0400
commitc379e1776b003a8220aaf86d9f19923afea1e854 (patch)
treeadb1a1a882ffd512b1e9f03975e920499e52c50e
parent512e637152aeb6586329bbcf074c2f2aa17e94aa (diff)
downloadegit-c379e1776b003a8220aaf86d9f19923afea1e854.tar.gz
egit-c379e1776b003a8220aaf86d9f19923afea1e854.tar.xz
egit-c379e1776b003a8220aaf86d9f19923afea1e854.zip
Prevent NPE in ProjectUtil.getProjectsUnderPath(IPath)
Bug: 491369 Change-Id: Ib7ce3f556ba2c53dbb5d3e001623a6f28c7c1c2f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> (cherry picked from commit b3a2709fe5f93c9cf575d9a5d6dd206ea66abe26)
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java
index bd2668254..1fe0845b1 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/util/ProjectUtil.java
@@ -39,6 +39,7 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.egit.core.internal.CoreText;
import org.eclipse.egit.core.project.RepositoryMapping;
+import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryCache.FileKey;
@@ -398,13 +399,16 @@ public class ProjectUtil {
* absolute path under which to look for projects
* @return projects located under the given path
*/
- public static IProject[] getProjectsUnderPath(final IPath path) {
+ public static IProject[] getProjectsUnderPath(@NonNull final IPath path) {
IProject[] allProjects = getProjectsForContainerMatch(ResourcesPlugin
.getWorkspace().getRoot());
Set<IProject> projects = new HashSet<IProject>();
- for (IProject p : allProjects)
- if (path.isPrefixOf(p.getLocation()))
+ for (IProject p : allProjects) {
+ IPath loc = p.getLocation();
+ if (loc != null && path.isPrefixOf(loc)) {
projects.add(p);
+ }
+ }
return projects.toArray(new IProject[projects.size()]);
}

Back to the top