diff options
author | Simon Rettberg | 2017-08-02 13:53:04 +0200 |
---|---|---|
committer | Simon Rettberg | 2017-08-02 13:53:04 +0200 |
commit | eda7aa2f58ba887c025f82a78b03db3d52e1f160 (patch) | |
tree | 89027a07a10f1d0c2b3e3ab0b96453917f1b885e /dozentenmodul/src/main/java/org/openslx/dozmod/App.java | |
parent | [server] Downgrade mysql-connector again to support Java 1.7 (diff) | |
download | tutor-module-eda7aa2f58ba887c025f82a78b03db3d52e1f160.tar.gz tutor-module-eda7aa2f58ba887c025f82a78b03db3d52e1f160.tar.xz tutor-module-eda7aa2f58ba887c025f82a78b03db3d52e1f160.zip |
[client] Fix update checks if behind proxy
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/App.java')
-rwxr-xr-x | dozentenmodul/src/main/java/org/openslx/dozmod/App.java | 26 |
1 files changed, 16 insertions, 10 deletions
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() { |