Skip to content

Commit

Permalink
ensure agent jars removed when process dies
Browse files Browse the repository at this point in the history
  • Loading branch information
hcoles committed Feb 5, 2025
1 parent b46f042 commit bb8f5d7
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.pitest.classpath.ClassPathByteArraySource;
import java.util.Optional;
import org.pitest.process.JavaAgent;
import org.pitest.util.FileUtil;
import org.pitest.util.PitError;
import org.pitest.util.Unchecked;

Expand Down Expand Up @@ -68,10 +67,14 @@ public Optional<String> getJarLocation() {
private Optional<String> createJar() {
try {

final File randomName = File.createTempFile(FileUtil.randomFilename(),
final File randomName = File.createTempFile("pitest-agent",
".jar");

final FileOutputStream fos = new FileOutputStream(randomName);
createJarFromClassPathResources(fos, randomName.getAbsolutePath());

randomName.deleteOnExit();

return Optional.ofNullable(randomName.getAbsolutePath());

} catch (final IOException ex) {
Expand Down

0 comments on commit bb8f5d7

Please sign in to comment.