@@ -66,34 +66,40 @@ public static void checkHTTPSSupport(LogService log) {
6666 connection .setRequestMethod ("HEAD" );
6767 connection .setConnectTimeout (10000 );
6868 } catch (ProtocolException e ) {
69- e .printStackTrace ();
69+ if (log != null ) log .error (e );
70+ else e .printStackTrace ();
7071 }
7172 try {
7273 connection .getResponseCode ();
7374 secureMode = true ;
7475 } catch (UnknownHostException e ) {
7576 String msg = "Could not determine the IP address of https://imagej.net. "
7677 + "Make sure you are connected to a network." ;
77- if (log != null ) log .warn (msg );
78- else System .out .println ("[WARNING] " + msg );
78+ warn (log , msg , e );
7979 offlineMode = true ;
8080 } catch (SSLHandshakeException e ) {
8181 secureMode = false ;
8282 String msg = "Your Java might be too old to handle updates via HTTPS. This is a security risk. " +
8383 "Depending on your setup please download a recent version of this software or update your local Java installation." ;
84- if (log != null ) log .warn (msg );
85- else System .out .println ("[WARNING] " + msg );
84+ warn (log , msg , e );
8685 } catch (SocketTimeoutException e ) {
8786 secureMode = false ;
8887 String msg = "Timeout while trying to update securely via HTTPS. Will fall back to HTTP. This is a security risk. " +
8988 "Please contact your system administrator to enable communication via HTTPS." ;
90- if (log != null ) log .warn (msg );
91- else System .out .println ("[WARNING] " + msg );
89+ warn (log , msg , e );
9290 } catch (IOException e ) {
9391 e .printStackTrace ();
9492 }
9593 }
9694
95+ private static void warn (final LogService log , final String msg , final Throwable t ) {
96+ if (log != null ) {
97+ if (log .isDebug ()) log .debug (msg , t );
98+ else log .warn (msg );
99+ }
100+ else System .out .println ("[WARNING] " + msg );
101+ }
102+
97103 /**
98104 * @return whether this ImageJ instance can handle HTTPS
99105 */
0 commit comments