Skip to content

Commit

Permalink
Dont try to unzip files that are not zip files.
Browse files Browse the repository at this point in the history
Fixes some stack traces in the log when we have external generated source files.

PiperOrigin-RevId: 565358938
  • Loading branch information
Googler authored and copybara-github committed Oct 4, 2023
1 parent cb1ded5 commit 35ce5e0
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,18 @@ private void updateMaps(Set<Label> targets, BuildArtifacts newArtifacts) {
}
}

private static final ImmutableSet<String> JAR_ZIP_EXTENSIONS =
ImmutableSet.of("jar", "zip", "srcjar");

private static boolean hasJarOrZipExtension(Path p) {
String name = p.getFileName().toString();
int dot = name.indexOf('.');
if (dot < 0) {
return false;
}
return JAR_ZIP_EXTENSIONS.contains(name.substring(dot + 1));
}

@Override
public ProjectProto.Project updateProjectProto(ProjectProto.Project projectProto)
throws BuildException {
Expand Down Expand Up @@ -540,6 +552,7 @@ public ProjectProto.Project updateProjectProto(ProjectProto.Project projectProto
.filter(not(ai -> projectDefinition.isIncluded(ai.label())))
.map(ArtifactInfo::genSrcs)
.flatMap(List::stream)
.filter(ArtifactTrackerImpl::hasJarOrZipExtension)
.map(generatedExternalSrcFileCache::getCacheFile)
.filter(Optional::isPresent)
.map(Optional::get)
Expand Down

0 comments on commit 35ce5e0

Please sign in to comment.