Can't disable porxy

I have this basic function which should control proxy transport

my problem is that i've noticed that even after i disable the proxy

URLConnections still pass through the proxy, any ideas friends?

<code>

public void activateProxy(boolean proxyActivateFlag)

{

String proxyIP= params.getScannerIP();

if (proxyActivateFlag)

{

logger.reportToSingleTestLog(null,"Activating proxy: " + proxyIP);

System.setProperty( "proxySet", "true" );

System.setProperty( "http.proxyHost", proxyIP);

System.setProperty( "http.proxyPort", "8080" );

}

else

{

System.setProperty( "proxySet", "true" );

}

try {

Thread.sleep(2000); //might not be needed

} catch (InterruptedException e) {

e.printStackTrace();

}

}

</code>

[862 byte] By [koko191a] at [2007-11-26 19:20:48]
# 1

Your code doesn't make sense, but anyway, and contrary to what you may have read from sources more gullible than me, 'proxySet' has never done anything in the JDK and you can set it to whatever you like: true, false, green cheese, without making the slightest difference to your program.

Changing http.proxyHost/proxyPort has an effect in recent JDKs but in earlier ones it was only read once and the value cached. But just setting them and never clearing them can't do anything, can it?

See java.net.Proxy for what you want to do.

ejpa at 2007-7-9 21:39:27 > top of Java-index,Core,Core APIs...
# 2
Thanks for you replay, 1. why do u say my code does not make sense ?2. how can i set the proxty host and port to NONE ?otherways just wasn't fast enough, would really appreciate ur help
koko191a at 2007-7-9 21:39:27 > top of Java-index,Core,Core APIs...
# 3

Because you're setting proxySet to true whether you want it set or not, and you're not clearing the other properties when you want them clear, according to the value of 'proxyActivateFlag'.

Fortunately proxySet does nothing whatever you set it to so it doesn't matter.

Clearing the other properties may not work on older JDKs where I believe the value was read once and then cached.

ejpa at 2007-7-9 21:39:27 > top of Java-index,Core,Core APIs...
# 4
I get you, i came to use proxyset system's property because, URLconnection.openconnection("proxy") was too slow.i am now using setproxyhost("loopback") to disable my proxy, 127.0.0.1, what do you say about that ? do you know a better way to use proxy ?
koko191a at 2007-7-9 21:39:27 > top of Java-index,Core,Core APIs...
# 5
Never heard of it.See java.net.Proxy as recommended in reply #1.I don't understand the part about using something that does nothing because something else was too slow.
ejpa at 2007-7-9 21:39:27 > top of Java-index,Core,Core APIs...
# 6
This does work, connection now do pass the proxy set in the proxyset, i am just looking for a way to disable it nicely, currently as i wrote i am switching to the local host 127.0.0.1 , which is not so "clean".. is the a "none" constant ?to reset this fields?
koko191a at 2007-7-9 21:39:27 > top of Java-index,Core,Core APIs...
# 7
See java.net.Proxy as recommended in reply #1.Third time I've said this.
ejpa at 2007-7-9 21:39:27 > top of Java-index,Core,Core APIs...