You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2024/05/16 15:20:34 UTC

[Bug 69016] New: HttpURLConnection getOutputStream createCapacityException

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.tripodo@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 69016] HttpURLConnection getOutputStream createCapacityException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69016

--- Comment #1 from Raffaele Tripodo <ra...@3ware.it> ---
Created attachment 39719
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=39719&action=edit
exception screenshot

this is the exception thrown running this line:

DataOutputStream out = new DataOutputStream(conn.getOutputStream())

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


[Bug 69016] HttpURLConnection getOutputStream createCapacityException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69016

--- Comment #7 from Remy Maucherat <re...@apache.org> ---
The cause of the "bug" is that marTrailerSize is configured to -1. This used to
be allowed and used to set a "no limit" as documented, so the trailers would
really be unlimited in size. This is usually not a very good idea BTW.

However, following the last major refactoring to improve functionality (
https://github.com/apache/tomcat/commit/cbed8e1836962d43120b81ae99d8d1b349265749
), -1 is no longer an allowed value. The documentation was not fixed probably
as a result of not realizing the commit introduced that change. I'll have to
fix the documentation since there's no way to restore the previous capability.

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


[Bug 69016] HttpURLConnection getOutputStream createCapacityException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69016

--- Comment #8 from Christopher Schultz <ch...@christopherschultz.net> ---
We probably need an "InvalidArgumentException" with a nice error message as
well as a documentation-fix.

That error message is not readable by "normal people" :)

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


[Bug 69016] HttpURLConnection getOutputStream createCapacityException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69016

--- Comment #3 from Christopher Schultz <ch...@christopherschultz.net> ---
Also, an example of the full HTTP request including headers and body would be
very helpful, here.

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


[Bug 69016] HttpURLConnection getOutputStream createCapacityException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69016

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #2 from Mark Thomas <ma...@apache.org> ---
And the sample code used to generate the response that triggers this behaviour?

Looks like the Servlet isn't writing a response body so we need to see that
code.

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


[Bug 69016] HttpURLConnection getOutputStream createCapacityException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69016

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|blocker                     |normal

--- Comment #4 from Mark Thomas <ma...@apache.org> ---
Dropping priority to normal. It really was a blocker, I'd expect a faster
response to our questions.

I'll note at this point that without the requested information, this issue will
eventually get resolved as WORKSFORME given that the issue appears to be that
the Servlet isn't writing a response body.

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


[Bug 69016] HttpURLConnection getOutputStream createCapacityException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69016

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WORKSFORME
             Status|NEEDINFO                    |RESOLVED

--- Comment #5 from Mark Thomas <ma...@apache.org> ---
Resolving based on previous comment.

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


[Bug 69016] HttpURLConnection getOutputStream createCapacityException

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69016

--- Comment #6 from Raffaele Tripodo <ra...@3ware.it> ---
I've been busy and away from office in these weeks. When I posted this issue, I
just wanted to submit the problem to the community.

Anyway I confirm the presence of this problem in the releases after 9.0.87
(last one working). I experiend the same problem with 9.0.89 and 9.0.90.

Beacuse you have closed this request as resolved, I guess you have found the
problem too. I hope you'll address the situation and release the fix in the
next releases.

Thanks for your support

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