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

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P5
    • 23
    • Affects Version/s: None
    • Component/s: 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.

            Assignee:
            Nizar Benalla
            Reporter:
            Andrey Turbanov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: