https://bz.apache.org/bugzilla/show_bug.cgi?id=69016

            Bug ID: 69016
           Summary: HttpURLConnection getOutputStream
                    createCapacityException
           Product: Tomcat 9
           Version: 9.0.89
          Hardware: All
                OS: All
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: Util
          Assignee: dev@tomcat.apache.org
          Reporter: raffaele.trip...@3ware.it
  Target Milestone: -----

Hello,
a simple code to download pdf file (generated by a servlet) is working fine in
Apache Tomcat 9.0.87, but the same exact code throws an excpetion in Apache
Tomcat 9.0.89.

This is the code

                        URL url = URI.create(address).toURL();
                        HttpURLConnection conn = (HttpURLConnection)
url.openConnection();

                        if (!params.isEmpty())
                        {
                                byte[] postData = String.join("&",
params).getBytes(Charset.forName("UTF-8"));
                                int postDataLength = postData.length;

                                conn.setDoInput(true);
                                conn.setDoOutput(true);
                                conn.setRequestMethod("POST");
                                conn.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
                                conn.setRequestProperty("Content-Length",
Integer.toString(postDataLength));
                                conn.setRequestProperty("Charset", "utf-8");
                                conn.setConnectTimeout(1000 * 15);
                                conn.setReadTimeout(1000 * 30);

                                // here is the error!
                                try (DataOutputStream dos = new
DataOutputStream(conn.getOutputStream()))
                                {
                                        dos.write(postData);
                                        dos.flush();
                                        dos.close();
                                }
                        }

                        try (InputStream in = conn.getInputStream())
                        {
                                if (tempFile)
                                {
                                        file =
File.createTempFile("getUrlFile", ".tmp");

                                        try (FileOutputStream out = new
FileOutputStream(file))
                                        {
                                                copyBinaryStream(in, out);
                                        }
                                }

                                content = getTextStream(in);
                        }

The same code works fine in previous version.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to