jdk/test/java/net/Socks/SocksProxyVersion.java
changeset 16737 8f36190e097a
parent 8160 4257e268578e
child 20783 c0806cb8d4ae
--- a/jdk/test/java/net/Socks/SocksProxyVersion.java	Fri Apr 05 10:41:46 2013 -0700
+++ b/jdk/test/java/net/Socks/SocksProxyVersion.java	Fri Apr 05 12:12:34 2013 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6964547
+ * @bug 6964547 5001942
  * @run main/othervm SocksProxyVersion
  * @summary test socksProxyVersion system property
  */
@@ -34,6 +34,7 @@
 import java.net.SocketException;
 import java.io.DataInputStream;
 import java.io.IOException;
+import java.net.InetAddress;
 
 public class SocksProxyVersion implements Runnable {
     final ServerSocket ss;
@@ -56,13 +57,19 @@
         Thread serverThread = new Thread(this);
         serverThread.start();
 
-        System.setProperty("socksProxyHost", "localhost");
+        /*
+         * Retreving the IP Address of the machine
+         * since "localhost" is bypassed as a non-proxy host
+         */
+        String addr = InetAddress.getLocalHost().getHostAddress();
+
+        System.setProperty("socksProxyHost", addr);
         System.setProperty("socksProxyPort", Integer.toString(port));
 
         // SOCKS V4
         System.setProperty("socksProxyVersion", Integer.toString(4));
         try (Socket s = new Socket()) {
-            s.connect(new InetSocketAddress("localhost", port));
+            s.connect(new InetSocketAddress(addr, port));
         } catch (SocketException e) {
             // java.net.SocketException: Malformed reply from SOCKS server
             // This exception is OK, since the "server" does not implement
@@ -72,7 +79,7 @@
         // SOCKS V5
         System.setProperty("socksProxyVersion", Integer.toString(5));
         try (Socket s = new Socket()) {
-            s.connect(new InetSocketAddress("localhost", port));
+            s.connect(new InetSocketAddress(addr, port));
         } catch (SocketException e) { /* OK */ }
 
         serverThread.join();