From a3982900a3c2d586e1b6acd6343ecde9fa37fc46 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 9 Aug 2017 16:58:51 +0200 Subject: Prevent NumberFormatExceptions from breaking everything; NPE in PacProxySelector --- .../proxy/search/browser/firefox/FirefoxProxySearchStrategy.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/btr/proxy/search/browser/firefox/FirefoxProxySearchStrategy.java') diff --git a/src/main/java/com/btr/proxy/search/browser/firefox/FirefoxProxySearchStrategy.java b/src/main/java/com/btr/proxy/search/browser/firefox/FirefoxProxySearchStrategy.java index 228bc8c..77868e2 100644 --- a/src/main/java/com/btr/proxy/search/browser/firefox/FirefoxProxySearchStrategy.java +++ b/src/main/java/com/btr/proxy/search/browser/firefox/FirefoxProxySearchStrategy.java @@ -13,6 +13,7 @@ import com.btr.proxy.selector.misc.ProtocolDispatchSelector; import com.btr.proxy.selector.whitelist.ProxyBypassListSelector; import com.btr.proxy.util.Logger; import com.btr.proxy.util.Logger.LogLevel; +import com.btr.proxy.util.MiscUtil; import com.btr.proxy.util.PlatformUtil; import com.btr.proxy.util.PlatformUtil.Platform; import com.btr.proxy.util.ProxyException; @@ -91,7 +92,7 @@ public class FirefoxProxySearchStrategy implements ProxySearchStrategy { Properties settings = readSettings(); ProxySelector result = null; - int type = Integer.parseInt(settings.getProperty("network.proxy.type", "-1")); + int type = MiscUtil.parseInt(settings.getProperty("network.proxy.type", "-1")); switch (type) { case -1: // Use system settings Logger.log(getClass(), LogLevel.TRACE, "Firefox uses system settings"); @@ -236,7 +237,7 @@ public class FirefoxProxySearchStrategy implements ProxySearchStrategy { private void installSecureProxy(ProtocolDispatchSelector ps, Properties settings) throws NumberFormatException { String proxyHost = settings.getProperty("network.proxy.ssl", null); - int proxyPort = Integer.parseInt(settings.getProperty("network.proxy.ssl_port", "0")); + int proxyPort = MiscUtil.parseInt(settings.getProperty("network.proxy.ssl_port", "0")); if (proxyHost != null) { Logger.log(getClass(), LogLevel.TRACE, "Firefox secure proxy is {0}:{1}", proxyHost, proxyPort); ProxySelector p = ProxyUtil.parseProxySettings(proxyHost, Proxy.Type.HTTP, proxyPort); @@ -258,7 +259,7 @@ public class FirefoxProxySearchStrategy implements ProxySearchStrategy { Properties settings, String protocol) throws NumberFormatException { String proxyHost = settings.getProperty("network.proxy."+protocol, null); - int proxyPort = Integer.parseInt(settings.getProperty("network.proxy."+protocol+"_port", "0")); + int proxyPort = MiscUtil.parseInt(settings.getProperty("network.proxy."+protocol+"_port", "0")); if (proxyHost != null) { Proxy.Type type; if (protocol.startsWith("socks")) { -- cgit v1.2.3-55-g7522