-
Notifications
You must be signed in to change notification settings - Fork 83
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
MigrateHandlerInterceptor recipe migrates too much #622
Merged
timtebeek
merged 13 commits into
main
from
checkout-620-custom-handlerinterceptor-with-spring-boot-3-migration-does-not-compile
Nov 12, 2024
Merged
MigrateHandlerInterceptor recipe migrates too much #622
timtebeek
merged 13 commits into
main
from
checkout-620-custom-handlerinterceptor-with-spring-boot-3-migration-does-not-compile
Nov 12, 2024
Conversation
This file contains 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
jevanlingen
changed the title
Checkout 620 custom handlerinterceptor with spring boot 3 migration does not compile
MigrateHandlerInterceptor recipe migrates too much
Nov 8, 2024
…spring-boot-3-migration-does-not-compile
timtebeek
reviewed
Nov 11, 2024
src/main/java/org/openrewrite/java/spring/framework/MigrateHandlerInterceptor.java
Outdated
Show resolved
Hide resolved
Remove test that did not extend HandlerInterceptorAdapter at all
…spring-boot-3-migration-does-not-compile
timtebeek
reviewed
Nov 11, 2024
src/testWithSpringBoot_2_4/java/org/openrewrite/java/spring/MigrateHandlerInterceptorTest.java
Outdated
Show resolved
Hide resolved
timtebeek
reviewed
Nov 12, 2024
src/testWithSpringBoot_2_4/java/org/openrewrite/java/spring/MigrateHandlerInterceptorTest.java
Outdated
Show resolved
Hide resolved
jevanlingen
commented
Nov 12, 2024
src/main/java/org/openrewrite/java/spring/boot2/MigrateDatabaseCredentials.java
Show resolved
Hide resolved
timtebeek
reviewed
Nov 12, 2024
src/main/java/org/openrewrite/java/spring/framework/MigrateHandlerInterceptor.java
Outdated
Show resolved
Hide resolved
timtebeek
approved these changes
Nov 12, 2024
timtebeek
deleted the
checkout-620-custom-handlerinterceptor-with-spring-boot-3-migration-does-not-compile
branch
November 12, 2024 21:55
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.
What's changed?
Improve/Bugfix the
MigrateHandlerInterceptor
recipe to only migrate classes that directly extends the HandlerInterceptorAdapter.What's your motivation?
Migration is targeted broadly, so it can migrate
super
calls when it is not intended to. This can lead to bugs, seefor example.
Any additional context
The migration does now convert
super.preHandle(..)
toHandlerInterceptor.super.preHandle(..)
. According to mr unconditional, you should migrate toreturn true
. See this SO post for more information.Also this blog seems to suggest that this is the right move (as in, when you move from SB 2 to 3, you likely have a
return true
kind of implementation).There are two other methods avaliable in the HandlerInterceptorAdapter/HandlerInterceptor classes:
postHandle
andafterCompletion
. Both of them have empty default implementation, So maybe the recipe should be doing something else:super.preHandle(..)
->return true
super.postHandle(..)
-><remove super call>
super.afterCompletion(..)
-><remove super call>
Checklist