java.net.ProtocolException: Server redirected too many times (20)
After googling a lot, trying many different solutions suggested by various posts and nothing to my help, I discussed this with Sandy and came to know that its a typical known issue with JDK provided proxy authentication that code goes into recursive loop trying to resolve the proxy and fetch the URL content where server sends a 3xx code asking for the redirection. When enough of redirection has happened above mentioned ProtocolException is thrown. Better way to handle the proxy authentication is to use Apahce's HTTP Component's HttpClient.
So at the end I removed JDK provided proxy authentication to Apache HttpClient and its very clean, easy to use and overcomes JDK's proxy authentication problem very neatly. Apache HTTP Client is still under beta stage and not much of user guide sort of documentation is available except some examples showcasing the capabilities of Apache HTTP Components. For the easy reference below is the code excerpt for the basic proxy authentication for Apache HttpClient 4.0-beta2 I used in my code...
...With above you have a HttpClient object configured to pass through your proxy with authentication enabled... Happy "proxying"... :)
DefaultHttpClient httpclient = new DefaultHttpClient() ;
HttpHost proxy = new HttpHost( proxy.ip, proxy.port ) ;
httpclient.getParams().setParameter( ConnRoutePNames.DEFAULT_PROXY, proxy ) ;
String localhost = InetAddress.getLocalHost().getHostName() ;
NTCredentials credentials = new NTCredentials( proxy.username, proxy.password, localhost, proxy.domain ) ;
httpclient.getCredentialsProvider().setCredentials( AuthScope.ANY, credentials) ;