Skip to content

Enhance the MultiReadHttpServletRequest stream #721

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vishalya
Copy link
Member

@vishalya vishalya commented Jul 9, 2025

Description

MultiReadHttpServletRequest class returns the stream with the cached body of the request. But the overriden methods logic look wrong. Also giving an option to multiple bytes for better performance.

Additional context and related issues

@Chaho12 has idea on the issue with this code. @willmostly is the original author.

Release notes

(X) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required, with the following suggested text:

@cla-bot cla-bot bot added the cla-signed label Jul 9, 2025
@Chaho12
Copy link
Member

Chaho12 commented Jul 9, 2025

Typo in commit message. MultiReadHttpServletRequest misses t there.
Btw how about "Fix ServletInputStream behavior for MultiReadHttpServletRequest and add read override" or you can remove MultiReadHttpServletRequest.

Comment on lines +67 to +68
@Override
public int read(byte[] b, int off, int len)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also implement public int read(byte[] b)?

public int read(byte[] b, int off, int len)
throws IOException
{
return byteArrayInputStream.read(b, off, len);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to make this null-safe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

byteArrayInputStream is locally allocated, if that's what your concern is. It should not be null.

@mosabua
Copy link
Member

mosabua commented Jul 18, 2025

Is this good to to @vishalya @Chaho12 @oneonestar ?

@Chaho12
Copy link
Member

Chaho12 commented Jul 18, 2025

Seems ok. But don't forget to fix the commit message :)

Copy link
Member

@andythsu andythsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except for the commit msg

@vishalya vishalya changed the title Fix/enhance the MultiReadHttpServletReques stream Fix/enhance the MultiReadHttpServletRequest stream Jul 22, 2025
@vishalya vishalya changed the title Fix/enhance the MultiReadHttpServletRequest stream Enhance the MultiReadHttpServletRequest stream Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

6 participants