-
Notifications
You must be signed in to change notification settings - Fork 38k
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
Fix "array index out of bounds" problem reported by LGTM.com #23485
Conversation
@jbduncan Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@jbduncan Thank you for signing the Contributor License Agreement! |
Could you re-work the tests to avoid the use reflection? |
@rstoyanchev: The only reason for reflection is to test private method. Then one should implement a test for public methods. I find it better. But the tests already contained 2 tests for exactly this same private method and they of course use reflection. Be consistent. Either accept new reflection based tests or rework other already existing reflection based tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the reflection based tests OK in this case. If one prefers not to use reflection in the tests, then it should be handled in a separate issue, and that would be a huge change, because there are already many reflection based tests in Spring.
Hi @rstoyanchev @mentallurg, sorry for the delay in responding! I was on holiday and then catching up with work and IRL things. I wasn't sure about introducing a reflection-based test either, but I used the same reasoning that @mentallurg did and I decided to use reflection for consistency with the other tests. @rstoyanchev Would you prefer that I switch all the reflection-based tests in I'm not sure if either of you are Spring maintainers, but is there anything else you'd like me to do before this PR is merged in? :) |
@jbduncan, you can look at comments from people to see if there is a The People page can also be of assistance for the entire Spring portfolio: https://github.com/orgs/spring-projects/people |
spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java
Outdated
Show resolved
Hide resolved
That's valid reasoning. However, I don't see any reason that @rstoyanchev, WDYT? |
Hey @sbrannen, fancy meeting you here. :)
Oh cool, thank you for reminding me about that button and the existence of GitHub's "People" tab. Cheers! 👍 |
Also minor refactoring in decoding in order to tolerate the absence of a charset and treat as US_ASCII. See gh-23485
This PR has been merged. I removed the use of reflection by doing actual parsing and/or formatting with an encoded filename attribute. There were even some existing tests like that so I don't know why we had reflection there in the first place. The refactoring helped to uncover a small issue with tolerating |
Thanks @rstoyanchev! 👍 |
This PR is a follow-on to #23461.
Specifically the problem that this PR fixes is https://lgtm.com/projects/g/spring-projects/spring-framework/snapshot/fb09647cbd34d6a540dc6e9b7e86aa7bcbe8e223/files/spring-web/src/main/java/org/springframework/http/ContentDisposition.java#xcfd962975fb7b533:1.
Feedback and other thoughts are welcome!