From 03da4db386119cde700dfab5b83365db3279fd3b Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Sun, 3 Dec 2023 19:15:22 +0000 Subject: [PATCH] Add timeout when fetching response from downloader. --- src/main/java/me/kavin/piped/utils/DownloaderImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/kavin/piped/utils/DownloaderImpl.java b/src/main/java/me/kavin/piped/utils/DownloaderImpl.java index aef67cb..b401122 100644 --- a/src/main/java/me/kavin/piped/utils/DownloaderImpl.java +++ b/src/main/java/me/kavin/piped/utils/DownloaderImpl.java @@ -12,6 +12,8 @@ import java.net.HttpCookie; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class DownloaderImpl extends Downloader { @@ -110,8 +112,8 @@ public class DownloaderImpl extends Downloader { }, Multithreading.getCachedExecutor()); try { - return responseFuture.get(); - } catch (InterruptedException | ExecutionException e) { + return responseFuture.get(10, TimeUnit.SECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { throw new IOException(e); } }