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

Strange behavior of URLConnection with proxy

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P3
    • 7-pool, 8-pool
    • core-libs
    • None
    • behavioral
    • minimal
    • Hide
      The default behaviour of HttpURLConnection is altered to not fall back to a direct connection if the first proxy connection attempt fails. A new system property is introduced that make it possible to restore the previous behavior in order to limit the compatibility risks.
      Show
      The default behaviour of HttpURLConnection is altered to not fall back to a direct connection if the first proxy connection attempt fails. A new system property is introduced that make it possible to restore the previous behavior in order to limit the compatibility risks.
    • System or security property
    • JDK

    Description

      Summary

      HttpURLConnection falls back to a direct connection if the first proxy connection attempt fails. This behaviour is seen with Oracle JDK8u and Oracle JDK7u and is a bug.

      Problem

      The HttpURLConnection implementation of java.net.URLConnection::connect falls back to trying a direct connection when a proxy has been configured but the connection attempt to the proxy fails. This should not be the case.

      This behaviour has been fixed from JDK9 onwards, and this is a backport request to Oracle JDK8u and Oracle JDK7u.

      Solution

      The HttpURLConnection implementation of java.net.URLConnection::connect has been updated so that when a proxy is configured but the connection attempt to the proxy fails, there is a single connection retry to the same proxy ( rather than a direct connection ).

      The solution that is being proposed here is a combination of two issues, that results in the same behaviour as that of JDK11 (and subsequent releases). More specifically, JIRA issues JDK-8161016 and JDK-8183369. (The proposal is to backport the changes for both JDK-8161016 and JDK-8183369, since they are inherently related)

      Given the change in behaviour being proposed here, and the maturity of Oracle JDK 8u and Oracle JDK 7u, a new system property sun.net.http.fallbackToDirect is introduced to revert to the old behaviour (fallback to a direct connection if the first proxy connection attempt fails)

      Specification

      Add a new System Property for HttpURLConnection to fall back to the old functionality.

      Name: sun.net.http.fallbackToDirect

      Usage: indicates that the HttpURLConnection should fall back to direct connection if the first proxy connection attempt fails.

      Value: a boolean, false by default

      A release note JDK-8268881 has been added describing this behaviour change and the usage of the system property.

      Attachments

        Issue Links

          Activity

            People

              kravikumar Kiran Sidhartha Ravikumar (Inactive)
              shadowbug Shadow Bug
              Chris Hegarty, Daniel Fuchs
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: