Replace deprecated Jakarta Servlet methods and classes
org.openrewrite.java.migrate.jakarta.RemovalsServletJakarta10
This recipe replaces the classes and methods deprecated in Jakarta Servlet 6.0
Recipe source
GitHub, Issue Tracker, Maven Central
groupId: org.openrewrite.recipe
artifactId: rewrite-migrate-java
version: 2.12.0
This recipe is composed of more than one recipe. If you want to customize the set of recipes this is composed of, you can find and copy the GitHub source for the recipe from the link above.
Usage
This recipe has no required configuration options. It can be activated by adding a dependency on org.openrewrite.recipe:rewrite-migrate-java:2.12.0
in your build file or by running a shell command (in which case no build changes are needed):
Add the following to your
build.gradle
file:
Run
gradle rewriteRun
to run the recipe.
Definition
oldFullyQualifiedTypeName:
javax.servlet.http.HttpServletRequest
newFullyQualifiedTypeName:
jakarta.servlet.http.HttpServletRequest
oldFullyQualifiedTypeName:
javax.servlet.http.HttpServletRequestWrapper
newFullyQualifiedTypeName:
jakarta.servlet.http.HttpServletRequestWrapper
oldFullyQualifiedTypeName:
javax.servlet.http.HttpServletResponse
newFullyQualifiedTypeName:
jakarta.servlet.http.HttpServletResponse
oldFullyQualifiedTypeName:
javax.servlet.http.HttpServletResponseWrapper
newFullyQualifiedTypeName:
jakarta.servlet.http.HttpServletResponseWrapper
oldFullyQualifiedTypeName:
javax.servlet.http.HttpSession
newFullyQualifiedTypeName:
jakarta.servlet.http.HttpSession
oldFullyQualifiedTypeName:
javax.servlet.ServletContext
newFullyQualifiedTypeName:
jakarta.servlet.ServletContext
oldFullyQualifiedTypeName:
javax.servlet.UnavailableException
newFullyQualifiedTypeName:
jakarta.servlet.UnavailableException
methodPattern:
jakarta.servlet.http.HttpServletRequest isRequestedSessionIdFromUrl()
newMethodName:
isRequestedSessionIdFromURL
methodPattern:
jakarta.servlet.http.HttpServletRequestWrapper isRequestedSessionIdFromUrl()
newMethodName:
isRequestedSessionIdFromURL
methodPattern:
jakarta.servlet.http.HttpServletResponse encodeUrl(String)
newMethodName:
encodeURL
methodPattern:
jakarta.servlet.http.HttpServletResponseWrapper encodeUrl(String)
newMethodName:
encodeURL
methodPattern:
jakarta.servlet.http.HttpServletResponse encodeRedirectUrl(String)
newMethodName:
encodeRedirectURL
methodPattern:
jakarta.servlet.http.HttpServletResponseWrapper encodeRedirectUrl(String)"
newMethodName:
encodeRedirectURL
methodPattern:
jakarta.servlet.http.HttpSession getValue(String)
newMethodName:
getAttribute
methodPattern:
jakarta.servlet.http.HttpSession getValueNames()
newMethodName:
getAttributeNames
methodPattern:
jakarta.servlet.http.HttpSession putValue(String, Object)
newMethodName:
setAttribute
methodPattern:
jakarta.servlet.http.HttpSession removeValue(String)
newMethodName:
removeAttribute
methodPattern:
jakarta.servlet.http.HttpServletResponse setStatus(int, String)
argumentIndex:
1
methodPattern:
jakarta.servlet.http.HttpServletResponseWrapper setStatus(int, String)
argumentIndex:
1
methodPattern:
jakarta.servlet.ServletContext log(Exception, String)
newParameterNames:
[ex, str]
oldParameterNames:
[str, ex]
matchOverrides:
true
methodPattern:
jakarta.servlet.UnavailableException <constructor>(jakarta.servlet.Servlet, String)
argumentIndex:
0
methodPattern:
jakarta.servlet.UnavailableException <constructor>(int, jakarta.servlet.Servlet, String)
argumentIndex:
1
methodPattern:
jakarta.servlet.UnavailableException <constructor>(int, String)
newParameterNames:
[str, in]
oldParameterNames:
[in, str]
matchOverrides:
true
See how this recipe works across multiple open-source repositories
The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories.
Please contact Moderne for more information about safely running the recipes on your own codebase in a private SaaS.
Contributors
Anu Ramamoorthy, Tim te Beek
Last updated