From e6b29898b12a3547c24d23e41438bcefd49b56e9 Mon Sep 17 00:00:00 2001 From: Andreas Sandblad Date: Thu, 30 Sep 2010 12:04:00 +0200 Subject: Don't perform DNS lookup in android.net.Proxy.isLocalHost This fixes degrade introduced by: Switch to using public APIs instead of private ones. 536ff5a6d700a80dbd75adb737ec4b560fbed2dc Change-Id: I63cbea82d85d55d933bcfc9e7a311d1aa2324955 --- core/java/android/net/Proxy.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/core/java/android/net/Proxy.java b/core/java/android/net/Proxy.java index 22c30a5..c1fa5b4 100644 --- a/core/java/android/net/Proxy.java +++ b/core/java/android/net/Proxy.java @@ -24,9 +24,7 @@ import android.os.SystemProperties; import android.provider.Settings; import android.util.Log; -import java.net.InetAddress; import java.net.URI; -import java.net.UnknownHostException; import junit.framework.Assert; @@ -162,15 +160,15 @@ final public class Proxy { final URI uri = URI.create(url); final String host = uri.getHost(); if (host != null) { - if (host.equalsIgnoreCase("localhost")) { - return true; - } - if (InetAddress.getByName(host).isLoopbackAddress()) { + // TODO: InetAddress.isLoopbackAddress should be used to check + // for localhost. However no public factory methods exist which + // can be used without triggering DNS lookup if host is not localhost. + if (host.equalsIgnoreCase("localhost") || + host.equals("127.0.0.1") || + host.equals("[::1]")) { return true; } } - } catch (UnknownHostException uex) { - // Ignore (INetworkSystem.ipStringToByteArray) } catch (IllegalArgumentException iex) { // Ignore (URI.create) } -- cgit v1.1