Skip to content

Commit 6289ae3

Browse files
committed
fix a race-condition
1 parent cddc9db commit 6289ae3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,8 @@ protected boolean hasSeenCode() {
446446
public int run() throws IOException {
447447
startThreadPool();
448448
try {
449-
extractSource();
449+
CompletableFuture<?> sourceFuture = extractSource();
450+
sourceFuture.join(); // wait for source extraction to complete
450451
if (hasSeenCode()) { // don't bother with the externs if no code was seen
451452
extractExterns();
452453
}
@@ -589,7 +590,7 @@ public FileType fileType(Path f) {
589590
}
590591

591592
/** Extract all supported candidate files that pass the filters. */
592-
private void extractSource() throws IOException {
593+
private CompletableFuture<?> extractSource() throws IOException {
593594
// default extractor
594595
FileExtractor defaultExtractor =
595596
new FileExtractor(mkExtractorConfig(), outputConfig, trapCache);
@@ -636,7 +637,7 @@ private void extractSource() throws IOException {
636637
boolean hasTypeScriptFiles = extractedFiles.size() > 0;
637638

638639
// extract remaining files
639-
extractFiles(
640+
return extractFiles(
640641
filesToExtract, extractedFiles, extractors,
641642
f -> !(hasTypeScriptFiles && isFileDerivedFromTypeScriptFile(f, extractedFiles)));
642643
}

0 commit comments

Comments
 (0)