Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete beam-artifact temp file on exit #29219

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading