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

NegativeArraySizeException occurs in ChunkedOutputStream() with Integer.MAX_VALUE

    XMLWordPrintable

Details

    • b96
    • generic
    • generic

    Backports

      Description

        HttpURLConnection.getOutputStream() will throw NegativeArraySizeException, if Integer.MAX_VALUE is set as the chunk size, setChunkedStreamingMode(Integer.MAX_VALUE).

        Reproducible test:
        ------
        public class Test {
            public static void main(String[] args) throws Exception {
                //Specify the URL to which you can access
                URL url = new URL("http://www.google.com");
                HttpURLConnection uc = (HttpURLConnection)url.openConnection();
                uc.setDoOutput(true);
                uc.setChunkedStreamingMode(Integer.MAX_VALUE);
                OutputStream os = uc.getOutputStream();
            }
        }
        ------
        >: java Test
        Exception in thread "main" java.lang.NegativeArraySizeException
        at sun.net.www.http.ChunkedOutputStream.<init>(ChunkedOutputStream.java:128)
        at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1110)
        at Test.main(Test.java:12)

        Attachments

          Issue Links

            Activity

              People

                khazra Kurchi Subhra Hazra
                tbaba Tadayuki Baba (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: