Server redirected too many times

This is another nasty exception I came across today. I was developing a core java application that connects to internet via proxy. It was working fine with hardcoded values for username (domain\myname as username and secret as password). When I accepted the same strings as command line arguments, the process did quit with this. Server redirected too many times (20)

Finally I came to know that I made a mistake with the username. Double slash is wrong when we give the string as command line argument. So, the server is keep on asking the username and password, which broke the process once the threshold 20 exceeded.