Skip to content

Commit

Permalink
[7.1.0] Do not print errors when repository rules are interrupted (#2…
Browse files Browse the repository at this point in the history
…0662)

When the user interrupts a build with Ctrl+C during the download or
extraction of a file, no Starlark error should be printed. This is
achieved by propagating `InterruptedException`s instead of failing the
repository rule with an `IOException`.

Closes #20023.

Commit
a2d3f20

PiperOrigin-RevId: 578869315
Change-Id: I9dd901ed87ed00c239599877816c6836688c1e16

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
Co-authored-by: Xùdōng Yáng <wyverald@gmail.com>
Co-authored-by: Ian (Hee) Cha <heec@google.com>
  • Loading branch information
4 people authored Jan 9, 2024
1 parent 81f3146 commit ed38b62
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.devtools.build.skyframe.SkyFunctionException.Transience;
import com.google.devtools.build.skyframe.SkyValue;
import java.io.IOException;
import java.nio.channels.ClosedByInterruptException;
import java.util.Optional;
import java.util.Set;
import net.starlark.java.eval.Starlark;
Expand Down Expand Up @@ -128,6 +129,8 @@ public static Path decompress(DecompressorDescriptor descriptor)
throws RepositoryFunctionException, InterruptedException {
try {
return getDecompressor(descriptor.archivePath()).decompress(descriptor);
} catch (ClosedByInterruptException e) {
throw new InterruptedException();
} catch (IOException e) {
Path destinationDirectory = descriptor.archivePath().getParentDirectory();
throw new RepositoryFunctionException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,6 @@ public StructImpl download(
if (executable) {
outputPath.getPath().setExecutable(true);
}
} catch (InterruptedException e) {
throw new RepositoryFunctionException(
new IOException("thread interrupted"), Transience.TRANSIENT);
} catch (IOException e) {
if (allowFail) {
return StarlarkInfo.create(
Expand Down Expand Up @@ -692,10 +689,6 @@ public StructImpl downloadAndExtract(
env.getListener(),
envVariables,
getIdentifyingStringForLogging());
} catch (InterruptedException e) {
env.getListener().post(w);
throw new RepositoryFunctionException(
new IOException("thread interrupted"), Transience.TRANSIENT);
} catch (IOException e) {
env.getListener().post(w);
if (allowFail) {
Expand Down

0 comments on commit ed38b62

Please sign in to comment.