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

Replace deprecated method #13649

Merged
merged 1 commit into from
Oct 2, 2023
Merged

Replace deprecated method #13649

merged 1 commit into from
Oct 2, 2023

Conversation

limvik
Copy link
Contributor

@limvik limvik commented Aug 14, 2023

Hello, I replaced HttpMethod.resolve() to HttpMethod.valueOf()

HttpMethod.resolve() is deprecated since Spring Framework 6.0.

Thank you.

Replace HttpMethod.resolve() to HttpMethod.valueOf()
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 14, 2023
@@ -66,7 +66,7 @@ public DispatcherTypeRequestMatcher(DispatcherType dispatcherType, @Nullable Htt
@Override
public boolean matches(HttpServletRequest request) {
if (this.httpMethod != null && StringUtils.hasText(request.getMethod())
&& this.httpMethod != HttpMethod.resolve(request.getMethod())) {
&& this.httpMethod != HttpMethod.valueOf(request.getMethod())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

as I read the deprecated method:

https://github.com/spring-projects/spring-framework/blob/6.0.x/spring-web/src/main/java/org/springframework/http/HttpMethod.java#L138

it seems to have a null-check.

I wonder if you also need a null check here (request.getMethod() == null)?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not needed since that condition is checked on line 68 with StringUtils.hasText(request.getMethod())

@jesperronn
Copy link
Contributor

looks good to me, but if request.getMethod() can be null it needs a null check?

If request.getMethod() == null and no null check is introduced, then it will change behaviour slightly

# Before:
HttpMethod.resolve(null) => null

# After:
HttpMethod.valueOf(null) => new HttpMethod(null) 

I dont know if that is a significant change or it will ever make a difference.

@jzheaux jzheaux self-assigned this Oct 2, 2023
@jzheaux jzheaux added in: web An issue in web modules (web, webmvc) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 2, 2023
@jzheaux jzheaux added this to the 6.1.5 milestone Oct 2, 2023
@jzheaux jzheaux merged commit d8eadd2 into spring-projects:6.1.x Oct 2, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web An issue in web modules (web, webmvc) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants