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)