Skip to content

Commit

Permalink
Do not print errors when repository rules are interrupted
Browse files Browse the repository at this point in the history
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.

PiperOrigin-RevId: 578869315
Change-Id: I9dd901ed87ed00c239599877816c6836688c1e16
  • Loading branch information
fmeum authored and copybara-github committed Nov 2, 2023
1 parent c7e391c commit a2d3f20
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 a2d3f20

Please sign in to comment.