Add recipe to migrate Filter to OncePerRequestFilter#911
Closed
jkschneider wants to merge 1 commit intomainfrom
Closed
Add recipe to migrate Filter to OncePerRequestFilter#911jkschneider wants to merge 1 commit intomainfrom
jkschneider wants to merge 1 commit intomainfrom
Conversation
Adds a new recipe that migrates classes implementing javax.servlet.Filter (or jakarta.servlet.Filter) to extend Spring's OncePerRequestFilter. The recipe performs the following transformations: - Changes `implements Filter` to `extends OncePerRequestFilter` - Renames `doFilter` method to `doFilterInternal` - Changes visibility from public to protected - Changes parameter types from ServletRequest/ServletResponse to HttpServletRequest/HttpServletResponse - Adds @OverRide annotation to doFilterInternal - Removes empty init() and destroy() methods Fixes moderneinc/customer-requests#1740
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.
What's Changed
Adds a new recipe
MigrateFilterToOncePerRequestFilterthat migrates classes implementingjavax.servlet.Filter(orjakarta.servlet.Filter) to extend Spring'sOncePerRequestFilter.The recipe performs the following transformations:
implements Filtertoextends OncePerRequestFilterdoFiltermethod todoFilterInternalServletRequest/ServletResponsetoHttpServletRequest/HttpServletResponse@Overrideannotation todoFilterInternalinit()anddestroy()methods (preserves non-empty ones)Filter, Serializable)Context
This recipe helps with migrating from raw servlet Filters (commonly used in Acegi 1) to Spring's
OncePerRequestFilterwhich became the standard in Spring Security 3+.Testing
Added comprehensive test cases covering:
Checklist