From eda7aa2f58ba887c025f82a78b03db3d52e1f160 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 2 Aug 2017 13:53:04 +0200 Subject: [client] Fix update checks if behind proxy --- .../src/main/java/org/openslx/dozmod/App.java | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'dozentenmodul/src/main/java') diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java index 292725c8..53654270 100755 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java @@ -10,6 +10,7 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.HashSet; import java.util.Set; +import java.util.concurrent.CountDownLatch; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -47,7 +48,9 @@ public class App { public static final int THRIFT_TIMEOUT_MS = 15000; - private static Thread proxyThread = null; + private static CountDownLatch proxyLatch = new CountDownLatch(1); + + private static boolean proxyInitDone = false; private static String masterServerHost = null; @@ -187,16 +190,20 @@ public class App { } // remember masterserver host masterServerHost = host; - // now start the proxy + // now start the proxy detection if (Config.getProxyMode() == ProxyMode.AUTO) { // Initialize the proxy settings - proxyThread = new Thread() { + new Thread() { @Override public void run() { ProxyConfigurator.init(); + proxyInitDone = true; + proxyLatch.countDown(); } - }; - proxyThread.start(); + }.start(); + } else { + proxyInitDone = true; + proxyLatch.countDown(); } // SSL if (useSsl) { @@ -317,18 +324,17 @@ public class App { * just the proxy setup, so this should be used before any network * communication happens. */ - public static synchronized void waitForInit() { - if (proxyThread == null) + public static void waitForInit() { + if (proxyInitDone) return; try { - proxyThread.join(); + proxyLatch.await(); } catch (InterruptedException e) { } - proxyThread = null; } public static synchronized boolean isInitDone() { - return proxyThread == null; + return proxyInitDone; } public static synchronized String getMasterServerAddress() { -- cgit v1.2.3-55-g7522