Skip to content

Commit

Permalink
Timeouts on file downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
goulven authored and goulven committed Oct 9, 2024
1 parent 759d991 commit 1b7957f
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ public File downloadToTmpFile(String url, String safeName) throws IOException {
try {
// Handle HTTP/HTTPS URLs
if (url.startsWith("http")) {
FileUtils.copyURLToFile(new URL(url), destFile);
//TODO(p3,conf) : timeouts from config
FileUtils.copyURLToFile(new URL(url), destFile, 30000, 30000);
}
// Handle classpath resources if necessary (currently commented out)
// else if (url.startsWith(CLASSPATH_PREFIX)) {
Expand Down Expand Up @@ -281,7 +282,8 @@ public File download(final String url,final File tmpFile) throws TechnicalExcept

try {
logger.info("Downloading resource from {} to {}", url, tmpFile);
FileUtils.copyURLToFile(new URL(url), tmpFile);
//TODO(p3,conf) : timeouts from config
FileUtils.copyURLToFile(new URL(url), tmpFile, 30000, 30000);
return tmpFile;
} catch (Exception e) {
throw new TechnicalException("Cannot download resource " + url + " : " + e.getMessage());
Expand Down

0 comments on commit 1b7957f

Please sign in to comment.