Skip to content

Commit

Permalink
Delete on exit beam-artifact temp file (#29219)
Browse files Browse the repository at this point in the history
  • Loading branch information
Abacn authored Oct 31, 2023
1 parent e2a7ea6 commit a036a18
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkArgument;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
Expand Down Expand Up @@ -391,7 +392,8 @@ private static List<RunnerApi.ArtifactInformation> resolveArtifacts(
.build())
.getReplacementsList()) {
Path path = Files.createTempFile("beam-artifact", "");
try (FileOutputStream fout = new FileOutputStream(path.toFile())) {
File artifactFile = path.toFile();
try (FileOutputStream fout = new FileOutputStream(artifactFile)) {
for (Iterator<ArtifactApi.GetArtifactResponse> it =
retrievalStub.getArtifact(
ArtifactApi.GetArtifactRequest.newBuilder().setArtifact(artifact).build());
Expand All @@ -409,6 +411,8 @@ private static List<RunnerApi.ArtifactInformation> resolveArtifacts(
.build()
.toByteString())
.build());
// Delete beam-artifact temp File on program exit
artifactFile.deleteOnExit();
}
return resolved;
}
Expand Down

0 comments on commit a036a18

Please sign in to comment.