From ec607b2e65b3e5ed1258c9bdaed3ab6ef962ded2 Mon Sep 17 00:00:00 2001 From: Dek Date: Sun, 30 Aug 2026 11:50:38 -0400 Subject: [PATCH] Fixed the proxy checker deadlocking once the queue empties --- .../meteorclient/systems/proxies/Proxies.java | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/proxies/Proxies.java b/src/main/java/meteordevelopment/meteorclient/systems/proxies/Proxies.java index c56887cdec9..49bd42cec6c 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/proxies/Proxies.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/proxies/Proxies.java @@ -26,8 +26,8 @@ public class Proxies extends System implements Iterable { .name("threads") .description("The number of concurrent threads to check proxies with.") .defaultValue(8) - .min(0) - .sliderRange(0, 32) + .min(1) + .sliderRange(1, 32) .build() ); @@ -150,12 +150,7 @@ public void checkProxies(boolean all) { try (ExecutorService executor = Executors.newFixedThreadPool(threads.get())) { for (int i = 0; i < threads.get(); i++) { - executor.execute(() -> { - try { - check(toCheck, checked); - } catch (InterruptedException _) { - } - }); + executor.execute(() -> check(toCheck, checked)); } try { @@ -164,18 +159,19 @@ public void checkProxies(boolean all) { executor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); } catch (InterruptedException _) { } - + } finally { refreshing = false; } }); } - private void check(BlockingQueue queue, ConcurrentHashMap checks) throws InterruptedException { - while (!queue.isEmpty()) { - Proxy proxy = queue.take(); + private void check(BlockingQueue queue, ConcurrentHashMap checks) { + Proxy proxy; + + while ((proxy = queue.poll()) != null) { if (proxy.checkStatus() == 3 && checks.get(proxy) <= tries.get()) { checks.put(proxy, checks.get(proxy) + 1); - queue.put(proxy); + queue.offer(proxy); } } }