Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JdkConnector - BufferOverflow exceptions reading chunked encoding responses #5742

Open
nicobrevin opened this issue Sep 11, 2024 · 3 comments

Comments

@nicobrevin
Copy link

We've found that we can't use jdk-connector to read entities from servers that are using chunked encoding, or we get intermittent BufferOverflow exceptions. We're fairly sure this only happens with larger files and when accessed via HTTPS, but we've not proved that with complete certainty. We controlled the other endpoint so fixed it by setting the Content-Length in the response instead.

Found in jersey 2.41

Exception in thread "jdk-connector-14" java.lang.IllegalArgumentException: Buffer overflow
         at org.glassfish.jersey.jdk.connector.internal.Utils.appendBuffers(Utils.java:64)
         at org.glassfish.jersey.jdk.connector.internal.HttpParser.parse(HttpParser.java:82)
         at org.glassfish.jersey.jdk.connector.internal.HttpFilter.processRead(HttpFilter.java:99)
         at org.glassfish.jersey.jdk.connector.internal.HttpFilter.processRead(HttpFilter.java:27)
         at org.glassfish.jersey.jdk.connector.internal.Filter.onRead(Filter.java:116)
         at org.glassfish.jersey.jdk.connector.internal.SslFilter.handleRead(SslFilter.java:361)
         at org.glassfish.jersey.jdk.connector.internal.SslFilter.processRead(SslFilter.java:323)
         at org.glassfish.jersey.jdk.connector.internal.SslFilter.processRead(SslFilter.java:36)
         at org.glassfish.jersey.jdk.connector.internal.Filter.onRead(Filter.java:116)
         at org.glassfish.jersey.jdk.connector.internal.Filter.onRead(Filter.java:124)
         at org.glassfish.jersey.jdk.connector.internal.TransportFilter$3.completed(TransportFilter.java:262)

I'd love to give you a reproducer/failing test case if you can give me a pointer for how to set up the ReadChunkedEntity test to use SSL?

@jansupol
Copy link
Contributor

@nicobrevin You can check the SSLFilterTest and the subclasses, or also the subclasses of SslParentTest

@jansupol
Copy link
Contributor

jansupol commented Sep 17, 2024

You say the issue occurs only with the larger files. If the content length is too large to fit into 32bits (int) the 2.41 JdkConnector has issues with it. JdkConnector 2.44 changed the content length to use long. Perhaps you can check this issue with the latest Jersey. The stack trace looks like a different issue, though.

@nicobrevin
Copy link
Author

Perhaps you can check this issue with the latest Jersey

Yes, that's true, I remember raising that bug! I ended up abandoning using JdkConnector for that use case, but revisited for something else where the files were smaller (<4 GB) but wanted the async-ness (and PATCH support) that JdkConnector has.

I'll try and find some time to test this out and get back to you...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants