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

Add Javadoc for MockHttpServletResponse getContentLength method #31833

Closed
jtroussard opened this issue Dec 13, 2023 · 1 comment
Closed

Add Javadoc for MockHttpServletResponse getContentLength method #31833

jtroussard opened this issue Dec 13, 2023 · 1 comment
Assignees
Labels
in: test Issues in the test module in: web Issues in web modules (web, webmvc, webflux, websocket) type: documentation A documentation task
Milestone

Comments

@jtroussard
Copy link

public int getContentLength() {
return (int) this.contentLength;
}

Leveraged this Class, MockHttpServletResponse, to write some tests and initially found the behavior of this getter, getContentLength, confusing. After reaching this SO post and reading the process the poster followed in their comments, the source of my confusion became clear. That being, the content length was referring to the header value for Content-Length, not the response's payload length.

https://stackoverflow.com/questions/52005034/spring-boot-test-mockhttpservletresponse-getcontentlength-return-0-despite-of

Wondered if the team/maintainers would find any value in updating the docs with a hint that would help clarify to which "length" value the API is fetching... even though it is clearly included in the method name itself. With modern IDE's auto completing and bringing up tool tips, this might help draw the focus to the "content" part of the method name. Could extend this work to the Long version of the method as well.

Would be willing to raise a PR is there is consenses.

And not to wonder off on too much of a tangent here, perhaps a more direct method to calculate/verify the payload length might be a worthwhile contribution as well.

Thoughts?

Sorry for the double issue, originally posted from a non-personal account.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 13, 2023
@jhoeller jhoeller added in: test Issues in the test module in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 3, 2024
@bclozel bclozel changed the title Consider adding/updating documentation to clarify target return value for getContentLength method Add Javadoc for MockHttpServletResponse getContentLength method Jan 3, 2024
@bclozel bclozel added type: documentation A documentation task and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 3, 2024
@bclozel bclozel self-assigned this Jan 3, 2024
@bclozel bclozel added this to the 6.1.3 milestone Jan 3, 2024
@bclozel bclozel closed this as completed in f846d94 Jan 3, 2024
@bclozel
Copy link
Member

bclozel commented Jan 3, 2024

Thanks @jtroussard for the feedback, I went ahead and added documentation for that method. Hopefully this will help other community members.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module in: web Issues in web modules (web, webmvc, webflux, websocket) type: documentation A documentation task
Projects
None yet
Development

No branches or pull requests

4 participants