Skip to content

Commit

Permalink
Remove temporary directory on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
pzygielo committed Jan 29, 2023
1 parent cd43460 commit 9ff06bc
Showing 1 changed file with 5 additions and 2 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation
* Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -44,6 +44,7 @@
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.core.HttpHeaders;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.glassfish.admin.rest.Constants;
import org.glassfish.admin.rest.RestLogging;
Expand Down Expand Up @@ -470,7 +471,9 @@ public static String getMethodParameterList(CommandModel cm, boolean withType, b
public static File saveTemporaryFile(String fileName, InputStream fileStream) {
File file;
try {
file = Files.createTempDirectory("gf_uploads").resolve(fileName).toFile();
Path uploadDir = Files.createTempDirectory("gf_uploads");
uploadDir.toFile().deleteOnExit();
file = uploadDir.resolve(fileName).toFile();
} catch (IOException e) {
throw new IllegalStateException("Could not create a temp file for " + fileName, e);
}
Expand Down

0 comments on commit 9ff06bc

Please sign in to comment.