Skip to content

Commit

Permalink
[pulsar-functions] fix some IOExceptions when create functions from p…
Browse files Browse the repository at this point in the history
…ackage URL (apache#14553)
  • Loading branch information
freeznet authored Mar 16, 2022
1 parent 157b808 commit f0d166f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import javax.ws.rs.client.Entity;
Expand Down Expand Up @@ -144,7 +145,7 @@ public void completed(Response response) {
if (destinyPath.getParent() != null) {
Files.createDirectories(destinyPath.getParent());
}
Files.copy(inputStream, destinyPath);
Files.copy(inputStream, destinyPath, StandardCopyOption.REPLACE_EXISTING);
future.complete(null);
} catch (IOException e) {
future.completeExceptionally(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ static File downloadPackageFile(PulsarWorkerService worker, String packageName)
// use the Nar extraction directory as a temporary directory for downloaded files
tempDirectory = Paths.get(worker.getWorkerConfig().getNarExtractionDirectory());
}
Files.createDirectories(tempDirectory);
File file = Files.createTempFile(tempDirectory, "function", ".tmp").toFile();
worker.getBrokerAdmin().packages().download(packageName, file.toString());
return file;
Expand Down

0 comments on commit f0d166f

Please sign in to comment.