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

Duplicate variable assignement in jdk.internal.net.http.AuthenticationFilter#getCredentials

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P5 P5
    • 23
    • None
    • core-libs
    • b20

      There is suspicious place in the jdk.internal.net.http.AuthenticationFilter#getCredentials method:

              InetSocketAddress proxyAddress;
              if (proxy && (proxyAddress = req.proxy()) != null) {
                  // request sent to server through proxy
                  proxyAddress = req.proxy();
                  host = proxyAddress.getHostString();
                  port = proxyAddress.getPort();
                  protocol = "http"; // we don't support https connection to proxy
              } else {
                  // direct connection to server or proxy
                  host = uri.getHost();
                  port = uri.getPort();
                  protocol = uri.getScheme();
              }

      `proxyAddress` variable is assigned inside `if` condition and then reassigned in the _then_ body.
      One assignment is redundant and can be removed.

            nbenalla Nizar Benalla
            aturbanov Andrey Turbanov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: