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 >

# 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 >
