Restrict forwards in MockMvcWebConnection to 100#29557
Merged
simonbasle merged 2 commits intospring-projects:mainfrom Feb 7, 2023
Merged
Restrict forwards in MockMvcWebConnection to 100#29557simonbasle merged 2 commits intospring-projects:mainfrom
simonbasle merged 2 commits intospring-projects:mainfrom
Conversation
When a filter is configured to conditionally forward, and it is configured to handle FORWARD dispatches as well, and it prevents infinite forward loops by either extending OncePerRequestFilter or otherwise using request attributes, this can result in infinite forward loops in WebClient tests using MockMvcWebConnection. This change will restrict the maximum number of forwards in MockMvcWebConnection to 100. Closes spring-projectsgh-29483
Contributor
Author
simonbasle
suggested changes
Jan 20, 2023
Contributor
simonbasle
left a comment
There was a problem hiding this comment.
@manthanb thanks for the contribution. I think that throwing an exception as proposed in the original issue would be better, wdyt? The message can mention that there is a probable infinite loop and that it forwarded 100 times.
Contributor
|
@manthanb are you still able to work on this? (cf review above) |
Contributor
Author
|
Hi @simonbasle Very sorry I missed your last comment. Yes, I will make the changes and commit today. |
Contributor
|
(note: to be backported in 5.3.x, as tracked by gh-29866) |
simonbasle
approved these changes
Feb 7, 2023
Contributor
simonbasle
left a comment
There was a problem hiding this comment.
I went ahead and made the adjustments to throw rather than ignore
simonbasle
added a commit
that referenced
this pull request
Feb 7, 2023
This change restricts the maximum number of forwards in MockMvcWebConnection to 100, in case a forward is configured in a way that causes a loop. This is necessary in HtmlUnit backed tests, unlike in classic MockMvc tests in which the forwards are not actually resolved. See gh-29557 Closes gh-29866 Co-authored-by: Simon Baslé <sbasle@vmware.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a filter is configured to conditionally forward, and it is configured to handle FORWARD dispatches as well, and it prevents infinite forward loops by either extending OncePerRequestFilter or otherwise using request attributes, this can result in infinite forward loops in WebClient tests using MockMvcWebConnection. This change will restrict the maximum number of forwards in MockMvcWebConnection to 100.
Closes gh-29483