Fix a bug in parsing .afdo.imports files whereupon Blaze would crash if a line in that file wasn't empty but also didn't contain a colon.
MOS_MIGRATED_REVID=147589431
@@ -431,13 +431,21 @@ public class FdoSupport {
ImmutableMultimap.Builder<PathFragment, PathFragment> importBuilder =
ImmutableMultimap.builder();
for (String line : FileSystemUtils.iterateLinesAsLatin1(importsFile)) {
- if (!line.isEmpty()) {
- PathFragment key = new PathFragment(line.substring(0, line.indexOf(':')));
+ line = line.trim();
+ if (line.isEmpty()) {
+ continue;
+ }
+
+ int colonIndex = line.indexOf(':');
+ if (colonIndex < 0) {
+ continue;
+ }
+ PathFragment key = new PathFragment(line.substring(0, colonIndex));
if (key.isAbsolute()) {
throw new FdoException("Absolute paths not allowed in afdo imports file " + importsFile
+ ": " + key);
}
- for (String auxFile : line.substring(line.indexOf(':') + 1).split(" ")) {
+ for (String auxFile : line.substring(colonIndex + 1).split(" ")) {
if (auxFile.length() == 0) {
continue;
}
@@ -445,7 +453,6 @@ public class FdoSupport {
importBuilder.put(key, new PathFragment(auxFile));
}
}
- }
return importBuilder.build();
}
