From 86a963d444af9480677e7f6413841f6a5061c233 Mon Sep 17 00:00:00 2001 From: Omair Majid <omajid@redhat.com> Date: Wed, 9 Oct 2013 12:18:49 -0400 Subject: Remove duplicate key computation in proxy code --- ChangeLog | 6 ++++++ plugin/icedteanp/java/sun/applet/PluginProxySelector.java | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ba7d0d3..e761c4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-10-09 Omair Majid <oamjid@redhat.com> + + * plugin/icedteanp/java/sun/applet/PluginProxySelector.java + (computeKey): New method. + (getFromBrowser, checkCache): Call computeKey. + 2013-10-09 Omair Majid <omajid@redhat.com> * plugin/icedteanp/java/sun/applet/PluginAppletViewer.java diff --git a/plugin/icedteanp/java/sun/applet/PluginProxySelector.java b/plugin/icedteanp/java/sun/applet/PluginProxySelector.java index cb4f58d..25689f5 100644 --- a/plugin/icedteanp/java/sun/applet/PluginProxySelector.java +++ b/plugin/icedteanp/java/sun/applet/PluginProxySelector.java @@ -116,7 +116,7 @@ public class PluginProxySelector extends JNLPProxySelector { proxy = new Proxy(type, socketAddr); - String uriKey = uri.getScheme() + "://" + uri.getHost(); + String uriKey = computeKey(uri); proxyCache.put(uriKey, proxy); } else { PluginDebug.debug("Proxy ", proxyURI, " cannot be used for ", uri, ". Falling back to DIRECT"); @@ -145,8 +145,7 @@ public class PluginProxySelector extends JNLPProxySelector { * @return The cached Proxy. null if there is no suitable cached proxy. */ private Proxy checkCache(URI uri) { - - String uriKey = uri.getScheme() + "://" + uri.getHost(); + String uriKey = computeKey(uri); if (proxyCache.get(uriKey) != null) { return proxyCache.get(uriKey); } @@ -154,6 +153,11 @@ public class PluginProxySelector extends JNLPProxySelector { return null; } + /** Compute a key to use for the proxy cache */ + private String computeKey(URI uri) { + return uri.getScheme() + "://" + uri.getHost(); + } + public static String convertUriSchemeForProxyQuery(URI uri) throws URISyntaxException, UnsupportedEncodingException { // there is no easy way to get SOCKS proxy info. So, we tell mozilla that we want proxy for // an HTTP uri in case of non http/ftp protocols. If we get back a SOCKS proxy, we can -- cgit v1.2.3