Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8047390

java.net.ProtocolException exception throws and the default Authenticator is never invoked

XMLWordPrintable

    • x86
    • windows_7

      J2SE Version (please include all output from java -version flag):
      Occur with all current Java versions 1.7.0 to 1.9.0

      Does this problem occur on J2SE 7ux, 8ux? Yes / No (pick one)
      Yes


      Operating System Configuration Information (be specific):
      Any Windows system.


      Bug Description:

      Have a problem with NTLM authentication and HttpURLConnection, If the local user has not the needed access rights. In this case the server send correctly a HTTP status 401. The problem is that the HttpURLConnection repeat to login 20 times with the local user account. Have set our own Authenticator with Authenticator.setDefault() but this instance is never invoked. We receive the follow exception:

      java.net.ProtocolException: Server redirected too many times (20)
          at
      sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1846)
          at
      sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439)


      Curiously depends the behavior on the host name. It occur with localhost and 127.0.0.1. But it work expected with VB5.

      The expected behavior is that if the local user is failing then the Authenticator is ask for a different user.

      If the user was login once with the current windows account it is impossible to login again with another account and the Authenticator. The default Authenticator is never invoked. It throws:
      java.net.ProtocolException: Server redirected too many times (20)
          at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1846)
          at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439)

      instead to invoke Authenticator.

      Steps to Reproduce (be specific):
      Extract the zip(password.zip) file and run the batch file. It throw a java.net.ProtocolException: Server redirected too many times (20)

            michaelm Michael McMahon
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: