[JENKINS-8436] Successful build ends with NPE

Submitted by Marco Rothe
This commit is contained in:
Olivier Lamy committed 2011-03-10 22:26:52 +01:00
1 parent 888b9d3683
commit cc0113dafd
1 file changed
+16 -6
@@ -333,14 +333,24 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
}
private static String normalizePath(String relPath) {
// JENKINS-8525 FilenameUtils.normalize for ../foo returns null
if (StringUtils.isEmpty(relPath) || StringUtils.startsWith( relPath, "../" )) {
LOGGER.config("No need to normalize " + (StringUtils.isEmpty(relPath) ? "an empty path" : relPath));
relPath = StringUtils.trimToEmpty( relPath );
if (StringUtils.isEmpty( relPath )) {
LOGGER.config("No need to normalize an empty path.");
} else {
String tmp = FilenameUtils.normalize( relPath );
LOGGER.config("Normalized path " + relPath + " to "+tmp);
relPath = tmp;
if(FilenameUtils.indexOfLastSeparator( relPath ) == -1) {
LOGGER.config("No need to normalize "+relPath);
} else {
String tmp = FilenameUtils.normalize( relPath );
if(tmp == null) {
LOGGER.config("Path " + relPath + " can not be normalized (parent dir is unknown). Keeping as is.");
} else {
LOGGER.config("Normalized path " + relPath + " to "+tmp);
relPath = tmp;
}
relPath = FilenameUtils.separatorsToUnix( relPath );
}
}
LOGGER.fine("Returning path " + relPath);
return relPath;
}