If include scanning ends up throwing, shut down the corresponding parallel visitation. Otherwise, we are in the strange situation where the action is complete, but work done as part of its include scanning continues on in async threads.
@@ -501,6 +501,8 @@ public class LegacyIncludeScanner implements IncludeScanner {
Set<ArtifactWithInclusionContext> visitedInclusions = Sets.newConcurrentHashSet();
IncludeVisitor visitor = new IncludeVisitor(includeScanningHeaderData.getModularHeaders());
+
+ try {
// Process cmd line includes, if specified.
if (mainSource != null && !cmdlineIncludes.isEmpty()) {
visitor.processCmdlineIncludes(
@@ -577,6 +579,11 @@ public class LegacyIncludeScanner implements IncludeScanner {
frontier = adjacent;
}
}
+ } catch (IOException | InterruptedException | ExecException | MissingDepException e) {
+ // Careful: Do not leak visitation threads if we have an exception in the initial thread.
+ visitor.sync();
+ throw e;
+ }
}
private static void checkForInterrupt(String operation, Object source)
