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

Rename MockMVC matcher methods to prevent regression in user tests #30238

Merged

Conversation

simonbasle
Copy link
Contributor

@simonbasle simonbasle commented Mar 30, 2023

This commit changes the name of two recently introduced methods in the
MockRestRequestMatchers class for header and queryParam. These have
been found to cause false negatives in user tests, due to the new
overload taking precedence in some cases.

Namely, using a Matcher factory method which can apply to both List
and String will cause the compiler to select the newest list overload,
by instantiating a Matcher<Object>.

This can cause false negatives in user tests, failing tests that used
to pass because the Matcher previously applied to the first String in
the header or queryParam value list. For instance, equalsTo("a").

The new overloads are recent enough and this has enough potential to
cause an arbitrary number of user tests to fail that we break the API
to eliminate the ambiguity, by renaming the methods with a *List
suffix.

Closes gh-30220
Closes gh-30238
See gh-29953
See gh-28660

@simonbasle simonbasle added this to the 6.0.8 milestone Mar 30, 2023
@simonbasle simonbasle self-assigned this Mar 30, 2023
This commit changes the name of two recently introduced methods in the
`MockRestRequestMatchers` class for header and queryParam. These have
been found to cause false negatives in user tests, due to the new
overload taking precedence in some cases.

Namely, using a `Matcher` factory method which can apply to both `List`
and `String` will cause the compiler to select the newest list overload,
by instantiating a `Matcher<Object>`.

This can cause false negatives in user tests, failing tests that used
to pass because the Matcher previously applied to the first String in
the header or queryParam value list. For instance, `equalsTo("a")`.

The new overloads are recent enough and this has enough potential to
cause an arbitrary number of user tests to fail that we break the API
to eliminate the ambiguity, by renaming the methods with a `*List`
suffix.

Closes spring-projectsgh-30220
Close spring-projectsgh-30238
See spring-projectsgh-29953
See spring-projectsgh-28660
@simonbasle simonbasle added in: test Issues in the test module in: web Issues in web modules (web, webmvc, webflux, websocket) labels Mar 30, 2023
@simonbasle simonbasle added the status: backported An issue that has been backported to maintenance branches label Apr 4, 2023
@simonbasle
Copy link
Contributor Author

Backport issue: #30235

@simonbasle simonbasle merged commit 95883b9 into spring-projects:main Apr 4, 2023
2 checks passed
@simonbasle simonbasle deleted the gh30220-headerQueryParamList branch April 4, 2023 13:06
simonbasle added a commit that referenced this pull request Apr 4, 2023
This commit changes the name of two recently introduced methods in the
`MockRestRequestMatchers` class for header and queryParam. These have
been found to cause false negatives in user tests, due to the new
overload taking precedence in some cases.

Namely, using a `Matcher` factory method which can apply to both `List`
and `String` will cause the compiler to select the newest list overload,
by instantiating a `Matcher<Object>`.

This can cause false negatives in user tests, failing tests that used
to pass because the Matcher previously applied to the first String in
the header or queryParam value list. For instance, `equalsTo("a")`.

The new overloads are recent enough and this has enough potential to
cause an arbitrary number of user tests to fail that we break the API
to eliminate the ambiguity, by renaming the methods with a `*List`
suffix.

See gh-30220
See gh-30238
Closes gh-30235
mdeinum pushed a commit to mdeinum/spring-framework that referenced this pull request Jun 29, 2023
This commit changes the name of two recently introduced methods in the
`MockRestRequestMatchers` class for header and queryParam. These have
been found to cause false negatives in user tests, due to the new
overload taking precedence in some cases.

Namely, using a `Matcher` factory method which can apply to both `List`
and `String` will cause the compiler to select the newest list overload,
by instantiating a `Matcher<Object>`.

This can cause false negatives in user tests, failing tests that used
to pass because the Matcher previously applied to the first String in
the header or queryParam value list. For instance, `equalsTo("a")`.

The new overloads are recent enough and this has enough potential to
cause an arbitrary number of user tests to fail that we break the API
to eliminate the ambiguity, by renaming the methods with a `*List`
suffix.

Closes spring-projectsgh-30220
Closes spring-projectsgh-30238
See spring-projectsgh-29953
See spring-projectsgh-28660
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) status: backported An issue that has been backported to maintenance branches
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong MockRestRequestMatchers.header() method in spring-test being invoked (JDK issue?)
2 participants