Skip to content

Commit 6b287e0

Browse files
author
Vladimir Kotal
committed
make getProject() more robust
1 parent 9ccefb3 commit 6b287e0

File tree

1 file changed

+9
-4
lines changed
  • opengrok-indexer/src/main/java/org/opengrok/indexer/configuration

1 file changed

+9
-4
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Project.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,14 +341,19 @@ public static Project getProject(String path) {
341341
if (env.hasProjects()) {
342342
final String lpath = path.replace(File.separatorChar, '/');
343343
for (Project p : env.getProjectList()) {
344-
String pp = p.getPath();
344+
String projectPath = p.getPath();
345+
if (projectPath == null) {
346+
LOGGER.log(Level.WARNING, "Path of project {0} is not set", p.getName());
347+
return null;
348+
}
349+
345350
// Check if the project's path is a prefix of the given
346351
// path. It has to be an exact match, or the project's path
347352
// must be immediately followed by a separator. "/foo" is
348353
// a prefix for "/foo" and "/foo/bar", but not for "/foof".
349-
if (lpath.startsWith(pp)
350-
&& (pp.length() == lpath.length()
351-
|| lpath.charAt(pp.length()) == '/')) {
354+
if (lpath.startsWith(projectPath)
355+
&& (projectPath.length() == lpath.length()
356+
|| lpath.charAt(projectPath.length()) == '/')) {
352357
return p;
353358
}
354359
}

0 commit comments

Comments
 (0)