1515 */
1616package com .stackify .api .common .http ;
1717
18- import lombok .NonNull ;
1918import lombok .experimental .UtilityClass ;
2019import lombok .extern .slf4j .Slf4j ;
2120
@@ -35,26 +34,18 @@ public class HttpProxy {
3534 * @return Proxy from system settings
3635 */
3736 public static Proxy fromSystemProperties () {
38-
39- try {
40- String proxyHost = System .getProperty ("https.proxyHost" );
41- String proxyPort = System .getProperty ("https.proxyPort" );
42-
43- return build (proxyHost , Integer .parseInt (proxyPort ));
44-
45- } catch (Throwable t ) {
46- log .info ("Unable to read HTTP proxy information from system properties" , t );
47- }
48-
49- return Proxy .NO_PROXY ;
37+ return build (System .getProperty ("https.proxyHost" ), System .getProperty ("https.proxyPort" ));
5038 }
5139
52- public static Proxy build (@ NonNull final String httpProxyHost ,
53- @ NonNull final int httpProxyPort ) {
40+ public static Proxy build (final String httpProxyHost ,
41+ final String httpProxyPort ) {
5442
5543 try {
56- if (!httpProxyHost .isEmpty ()) {
57- return new Proxy (Proxy .Type .HTTP , new InetSocketAddress (httpProxyHost , httpProxyPort ));
44+ if (httpProxyHost != null &&
45+ !httpProxyHost .isEmpty () &&
46+ httpProxyPort != null &&
47+ !httpProxyPort .isEmpty ()) {
48+ return new Proxy (Proxy .Type .HTTP , new InetSocketAddress (httpProxyHost , Integer .parseInt (httpProxyPort )));
5849 }
5950 } catch (Throwable t ) {
6051 log .info ("Unable to read HTTP proxy information from system properties" , t );
0 commit comments