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

http.nonProxyHosts=* causes StringIndexOutOfBoundsException in DefaultProxySelector

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Build:
      b12
    • Introduced In Version:
      11
    • Resolved In Build:
      b18
    • Verification:
      Verified

      Backports

        Description

        A DESCRIPTION OF THE PROBLEM :
        12:25:19 [junit] 12:25:19,375 INFO [MyTest] System property 'http.nonProxyHosts' = '*'

        <snip>
        12:25:49 [junit] Caused by: java.lang.StringIndexOutOfBoundsException: begin 1, end 0, length 1
        12:25:49 [junit] at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3319)
        12:25:49 [junit] at java.base/java.lang.String.substring(String.java:1874)
        12:25:49 [junit] at java.base/sun.net.spi.DefaultProxySelector.disjunctToRegex(DefaultProxySelector.java:399)
        12:25:49 [junit] at java.base/sun.net.spi.DefaultProxySelector.toPattern(DefaultProxySelector.java:386)
        12:25:49 [junit] at java.base/sun.net.spi.DefaultProxySelector$4.run(DefaultProxySelector.java:281)
        12:25:49 [junit] at java.base/sun.net.spi.DefaultProxySelector$4.run(DefaultProxySelector.java:223)
        12:25:49 [junit] at java.base/java.security.AccessController.doPrivileged(Native Method)
        12:25:49 [junit] at java.base/sun.net.spi.DefaultProxySelector.select(DefaultProxySelector.java:222)


        It looks like the fix http://mail.openjdk.java.net/pipermail/net-dev/2018-March/011223.html for https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8144300 didn't consider the "*" case.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        javac Main.java && java Main

        using code below

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@24a35978
        ACTUAL -
        java.lang.StringIndexOutOfBoundsException: begin 1, end 0, length 1
        at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3319)
        at java.base/java.lang.String.substring(String.java:1874)
        at java.base/sun.net.spi.DefaultProxySelector.disjunctToRegex(DefaultProxySelector.java:399)
        at java.base/sun.net.spi.DefaultProxySelector.toPattern(DefaultProxySelector.java:386)
        at java.base/sun.net.spi.DefaultProxySelector$4.run(DefaultProxySelector.java:281)
        at java.base/sun.net.spi.DefaultProxySelector$4.run(DefaultProxySelector.java:223)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.base/sun.net.spi.DefaultProxySelector.select(DefaultProxySelector.java:222)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1181)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1081)
        at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1587)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1515)
        at java.base/java.net.URLConnection.getContent(URLConnection.java:749)
        at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getContent(HttpsURLConnectionImpl.java:430)
        at java.base/java.net.URL.getContent(URL.java:1154)
        at Main.main(Main.java:11)


        ---------- BEGIN SOURCE ----------
        import java.net.URL;
        public class Main {

            public static void main(String[] args) {

                System.setProperty("https.proxyHost", "192.168.1.1");
                System.setProperty("http.proxyPort", "808");
                System.setProperty("http.nonProxyHosts", "*");
                try {
                    URL url=new URL("https://google.com");
                    System.out.println(url.getContent());
                } catch(Exception e) {
                    e.printStackTrace();
                }
            }
        }

        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        System.setProperty("http.nonProxyHosts", "**");

        FREQUENCY : always


          Attachments

            Issue Links

              Activity

                People

                Assignee:
                jpai Jaikiran Pai
                Reporter:
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: