Skip to content

Commit 87ad78d

Browse files
authored
Merge pull request #750 from TeamPiped/downloader-timeout
Add timeout when fetching response from downloader
2 parents 665306b + 03da4db commit 87ad78d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/me/kavin/piped/utils/DownloaderImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import java.util.List;
1313
import java.util.Map;
1414
import java.util.concurrent.ExecutionException;
15+
import java.util.concurrent.TimeUnit;
16+
import java.util.concurrent.TimeoutException;
1517

1618
public class DownloaderImpl extends Downloader {
1719

@@ -110,8 +112,8 @@ public Response execute(Request request) throws IOException, ReCaptchaException
110112
}, Multithreading.getCachedExecutor());
111113

112114
try {
113-
return responseFuture.get();
114-
} catch (InterruptedException | ExecutionException e) {
115+
return responseFuture.get(10, TimeUnit.SECONDS);
116+
} catch (InterruptedException | ExecutionException | TimeoutException e) {
115117
throw new IOException(e);
116118
}
117119
}

0 commit comments

Comments
 (0)