diff --git a/src/main/java/org/openrewrite/apache/httpclient5/MigrateAuthSchemeCredentials.java b/src/main/java/org/openrewrite/apache/httpclient5/MigrateAuthSchemeCredentials.java new file mode 100644 index 0000000..8f7cdfa --- /dev/null +++ b/src/main/java/org/openrewrite/apache/httpclient5/MigrateAuthSchemeCredentials.java @@ -0,0 +1,89 @@ +/* + * Copyright 2026 the original author or authors. + *

+ * Licensed under the Moderne Source Available License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://docs.moderne.io/licensing/moderne-source-available-license + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.apache.httpclient5; + +import lombok.EqualsAndHashCode; +import lombok.Value; +import org.openrewrite.Cursor; +import org.openrewrite.ExecutionContext; +import org.openrewrite.Recipe; +import org.openrewrite.TreeVisitor; +import org.openrewrite.java.JavaParser; +import org.openrewrite.java.JavaTemplate; +import org.openrewrite.java.JavaVisitor; +import org.openrewrite.java.MethodMatcher; +import org.openrewrite.java.tree.J; +import org.openrewrite.java.tree.Statement; +import org.openrewrite.java.tree.TypeUtils; + +@EqualsAndHashCode(callSuper = false) +@Value +public class MigrateAuthSchemeCredentials extends Recipe { + + private static final String FQN_AUTH_EXCHANGE = "org.apache.hc.client5.http.auth.AuthExchange"; + private static final String FQN_AUTH_SCHEME = "org.apache.hc.client5.http.auth.AuthScheme"; + private static final String FQN_BASIC_SCHEME = "org.apache.hc.client5.http.impl.auth.BasicScheme"; + private static final String FQN_CREDENTIALS = "org.apache.hc.client5.http.auth.Credentials"; + + private static final MethodMatcher UPDATE = new MethodMatcher( + FQN_AUTH_EXCHANGE + " update(" + FQN_AUTH_SCHEME + ", " + FQN_CREDENTIALS + ")"); + private static final MethodMatcher GET_AUTH_SCHEME_ON_SCHEME = new MethodMatcher( + FQN_AUTH_SCHEME + " getAuthScheme()"); + + String displayName = "Migrate `AuthScheme` credential handling"; + + String description = "Rewrites `AuthExchange#update(BasicScheme, Credentials)` to `BasicScheme#initPreemptive(Credentials)` followed by `AuthExchange#select(AuthScheme)`. " + + "Unwraps leftover `AuthOption#getAuthScheme()` calls (now on `AuthScheme` after the type rename) to the receiver itself. " + + "Other `update`/`setCredentials`/`getCredentials` call sites are flagged separately by `AddCommentToMethodInvocations`."; + + @Override + public TreeVisitor getVisitor() { + return new JavaVisitor() { + @Override + public J.Block visitBlock(J.Block block, ExecutionContext ctx) { + J.Block b = (J.Block) super.visitBlock(block, ctx); + for (Statement stmt : b.getStatements()) { + if (!(stmt instanceof J.MethodInvocation)) { + continue; + } + J.MethodInvocation mi = (J.MethodInvocation) stmt; + if (!UPDATE.matches(mi) || + !TypeUtils.isOfClassType(mi.getArguments().get(0).getType(), FQN_BASIC_SCHEME)) { + continue; + } + b = JavaTemplate.builder( + "#{any(" + FQN_BASIC_SCHEME + ")}.initPreemptive(#{any(" + FQN_CREDENTIALS + ")});\n" + + "#{any(" + FQN_AUTH_EXCHANGE + ")}.select(#{any(" + FQN_AUTH_SCHEME + ")});") + .javaParser(JavaParser.fromJavaVersion().classpathFromResources(ctx, "httpclient5", "httpcore5")) + .build() + .apply(new Cursor(getCursor().getParent(), b), mi.getCoordinates().replace(), + mi.getArguments().get(0), mi.getArguments().get(1), + mi.getSelect(), mi.getArguments().get(0)); + } + return b; + } + + @Override + public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) { + J.MethodInvocation m = (J.MethodInvocation) super.visitMethodInvocation(method, ctx); + if (GET_AUTH_SCHEME_ON_SCHEME.matches(m) && m.getSelect() != null) { + return m.getSelect().withPrefix(m.getPrefix()); + } + return m; + } + }; + } +} diff --git a/src/main/resources/META-INF/rewrite/apache-httpclient-5.yml b/src/main/resources/META-INF/rewrite/apache-httpclient-5.yml index 186d7f3..1dfdc1f 100644 --- a/src/main/resources/META-INF/rewrite/apache-httpclient-5.yml +++ b/src/main/resources/META-INF/rewrite/apache-httpclient-5.yml @@ -37,6 +37,7 @@ recipeList: - org.openrewrite.apache.httpclient5.UsernamePasswordCredentials - org.openrewrite.apache.httpclient5.StatusLine - org.openrewrite.apache.httpclient5.UpgradeApacheHttpClient_5_ClassMapping + - org.openrewrite.apache.httpclient5.MigrateAuthState - org.openrewrite.apache.httpclient5.UpgradeApacheHttpClient_5_DeprecatedMethods - org.openrewrite.apache.httpclient5.UpgradeApacheHttpClient_5_TimeUnit - org.openrewrite.apache.httpclient5.MigrateAuthScope @@ -822,6 +823,43 @@ recipeList: newFullyQualifiedTypeName: org.apache.hc.client5.http.auth.CredentialsStore --- type: specs.openrewrite.org/v1beta/recipe +name: org.openrewrite.apache.httpclient5.MigrateAuthState +displayName: Migrate `AuthState` to `AuthExchange` +description: >- + Migrate Apache HttpClient 4.x `AuthState` and related types to the + HttpClient 5.x `AuthExchange` API, including the `AuthProtocolState` enum, + `AuthOption` queue elements, and credential-handling call sites. +tags: + - apache + - httpclient +recipeList: + - org.openrewrite.java.ChangeType: + oldFullyQualifiedTypeName: org.apache.hc.client5.http.auth.AuthState + newFullyQualifiedTypeName: org.apache.hc.client5.http.auth.AuthExchange + - org.openrewrite.java.ChangeType: + oldFullyQualifiedTypeName: org.apache.hc.client5.http.auth.AuthProtocolState + newFullyQualifiedTypeName: org.apache.hc.client5.http.auth.AuthExchange$State + - org.openrewrite.java.ChangeType: + oldFullyQualifiedTypeName: org.apache.hc.client5.http.auth.AuthOption + newFullyQualifiedTypeName: org.apache.hc.client5.http.auth.AuthScheme + - org.openrewrite.java.ChangeMethodName: + methodPattern: org.apache.hc.client5.http.auth.AuthExchange setAuthScheme(org.apache.hc.client5.http.auth.AuthScheme) + newMethodName: select + - org.openrewrite.java.ChangeMethodName: + methodPattern: org.apache.hc.client5.http.auth.AuthExchange setAuthOptions(java.util.Queue) + newMethodName: setOptions + - org.openrewrite.apache.httpclient5.MigrateAuthSchemeCredentials + - org.openrewrite.java.AddCommentToMethodInvocations: + comment: " HttpClient 5: credentials must be registered with a CredentialsProvider, not on AuthScheme. " + methodPattern: org.apache.hc.client5.http.auth.AuthExchange update(org.apache.hc.client5.http.auth.AuthScheme, org.apache.hc.client5.http.auth.Credentials) + - org.openrewrite.java.AddCommentToMethodInvocations: + comment: " HttpClient 5: credentials must be registered with a CredentialsProvider, not on AuthScheme. " + methodPattern: org.apache.hc.client5.http.auth.AuthExchange setCredentials(org.apache.hc.client5.http.auth.Credentials) + - org.openrewrite.java.AddCommentToMethodInvocations: + comment: " HttpClient 5: AuthScheme.getCredentials() is gone; credentials live on CredentialsProvider. " + methodPattern: org.apache.hc.client5.http.auth.AuthScheme getCredentials() +--- +type: specs.openrewrite.org/v1beta/recipe name: org.openrewrite.apache.httpclient5.UpgradeApacheHttpClient_5_AsyncClientClassMapping displayName: Migrate Apache HttpAsyncClient 4.x classes to HttpClient 5.x description: >- diff --git a/src/main/resources/META-INF/rewrite/recipes.csv b/src/main/resources/META-INF/rewrite/recipes.csv index d8fadec..54a3a4b 100644 --- a/src/main/resources/META-INF/rewrite/recipes.csv +++ b/src/main/resources/META-INF/rewrite/recipes.csv @@ -1,42 +1,42 @@ ecosystem,packageName,name,displayName,description,recipeCount,category1,category2,category3,category1Description,category2Description,category3Description,options maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.PreferJavaStandardLibrary,Prefer the Java standard library instead of Apache Commons,"Prefer the Java standard library instead of Apache Commons. These recipes replace various Apache Commons utilities with their JDK equivalents, where available in Java 11+.",50,,Commons,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.codec.ApacheBase64ToJavaBase64,Prefer `java.util.Base64`,Prefer the Java standard library's `java.util.Base64` over third-party usage of apache's `apache.commons.codec.binary.Base64`.,1,Commons Codec,Commons,Apache,Recipes for [Apache Commons Codec](https://commons.apache.org/proper/commons-codec/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.io.ApacheCommonsFileUtilsRecipes,`ApacheCommonsFileUtils` Refaster recipes,Refaster template recipes for `org.openrewrite.apache.commons.io.ApacheCommonsFileUtils`.,8,Commons IO,Commons,Apache,Recipes for [Apache Commons IO](https://commons.apache.org/proper/commons-io/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.io.ApacheCommonsFileUtilsRecipes$GetFileRecipe,Replace `FileUtils.getFile(String...)` with JDK provided API,Replace Apache Commons `FileUtils.getFile(String... name)` with JDK provided API.,1,Commons IO,Commons,Apache,Recipes for [Apache Commons IO](https://commons.apache.org/proper/commons-io/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.io.ApacheCommonsFileUtilsRecipes$ReadFileToStringWithCharsetRecipe,"Replace `FileUtils.readFileToString(File)` with `FileUtils.readFileToString(File, StandardCharsets.UTF_8)`","Replace deprecated `FileUtils.readFileToString(File)` with `FileUtils.readFileToString(File, StandardCharsets.UTF_8)`.",1,Commons IO,Commons,Apache,Recipes for [Apache Commons IO](https://commons.apache.org/proper/commons-io/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.io.ApacheCommonsFileUtilsRecipes$ReadLinesWithCharsetRecipe,"Replace `FileUtils.readLines(File)` with `FileUtils.readLines(File, StandardCharsets.UTF_8)`","Replace deprecated `FileUtils.readLines(File)` with `FileUtils.readLines(File, StandardCharsets.UTF_8)`.",1,Commons IO,Commons,Apache,Recipes for [Apache Commons IO](https://commons.apache.org/proper/commons-io/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.io.ApacheCommonsFileUtilsRecipes$WriteAppendWithCharsetRecipe,"Replace `FileUtils.write(File, CharSequence, boolean)` with `FileUtils.write(File, CharSequence, StandardCharsets.UTF_8, boolean)`","Replace deprecated `FileUtils.write(File, CharSequence, boolean)` with `FileUtils.write(File, CharSequence, StandardCharsets.UTF_8, boolean)`.",1,Commons IO,Commons,Apache,Recipes for [Apache Commons IO](https://commons.apache.org/proper/commons-io/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.io.ApacheCommonsFileUtilsRecipes$WriteStringToFileAppendWithCharsetRecipe,"Replace `FileUtils.writeStringToFile(File, String, boolean)` with `FileUtils.writeStringToFile(File, String, StandardCharsets.UTF_8, boolean)`","Replace deprecated `FileUtils.writeStringToFile(File, String, boolean)` with `FileUtils.writeStringToFile(File, String, StandardCharsets.UTF_8, boolean)`.",1,Commons IO,Commons,Apache,Recipes for [Apache Commons IO](https://commons.apache.org/proper/commons-io/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.io.ApacheCommonsFileUtilsRecipes$WriteStringToFileRecipe,"Replace `FileUtils.writeStringToFile(File, String)` with JDK provided API","Replace Apache Commons `FileUtils.writeStringToFile(File file, String data)` with JDK provided API.",1,Commons IO,Commons,Apache,Recipes for [Apache Commons IO](https://commons.apache.org/proper/commons-io/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.io.ApacheCommonsFileUtilsRecipes$WriteWithCharsetRecipe,"Replace `FileUtils.write(File, CharSequence)` with `FileUtils.write(File, CharSequence, StandardCharsets.UTF_8, false)`","Replace deprecated `FileUtils.write(File, CharSequence)` with `FileUtils.write(File, CharSequence, StandardCharsets.UTF_8, false)`.",1,Commons IO,Commons,Apache,Recipes for [Apache Commons IO](https://commons.apache.org/proper/commons-io/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.io.ApacheCommonsFileUtilsRecipes$ReadFileToStringWithCharsetRecipe,"Replace `FileUtils.readFileToString(File)` with `FileUtils.readFileToString(File, StandardCharsets.UTF_8)`","Replace deprecated `FileUtils.readFileToString(File)` with `FileUtils.readFileToString(File, StandardCharsets.UTF_8)`.",1,Commons IO,Commons,Apache,Recipes for [Apache Commons IO](https://commons.apache.org/proper/commons-io/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.io.ApacheFileUtilsToJavaFiles,Prefer `java.nio.file.Files`,Prefer the Java standard library's `java.nio.file.Files` over third-party usage of apache's `apache.commons.io.FileUtils`.,1,Commons IO,Commons,Apache,Recipes for [Apache Commons IO](https://commons.apache.org/proper/commons-io/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.io.ApacheCommonsFileUtilsRecipes$WriteWithCharsetRecipe,"Replace `FileUtils.write(File, CharSequence)` with `FileUtils.write(File, CharSequence, StandardCharsets.UTF_8, false)`","Replace deprecated `FileUtils.write(File, CharSequence)` with `FileUtils.write(File, CharSequence, StandardCharsets.UTF_8, false)`.",1,Commons IO,Commons,Apache,Recipes for [Apache Commons IO](https://commons.apache.org/proper/commons-io/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.io.ApacheCommonsFileUtilsRecipes$ReadLinesWithCharsetRecipe,"Replace `FileUtils.readLines(File)` with `FileUtils.readLines(File, StandardCharsets.UTF_8)`","Replace deprecated `FileUtils.readLines(File)` with `FileUtils.readLines(File, StandardCharsets.UTF_8)`.",1,Commons IO,Commons,Apache,Recipes for [Apache Commons IO](https://commons.apache.org/proper/commons-io/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.io.ApacheCommonsFileUtilsRecipes,`ApacheCommonsFileUtils` Refaster recipes,Refaster template recipes for `org.openrewrite.apache.commons.io.ApacheCommonsFileUtils`.,8,Commons IO,Commons,Apache,Recipes for [Apache Commons IO](https://commons.apache.org/proper/commons-io/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.io.ApacheCommonsFileUtilsRecipes$GetFileRecipe,Replace `FileUtils.getFile(String...)` with JDK provided API,Replace Apache Commons `FileUtils.getFile(String... name)` with JDK provided API.,1,Commons IO,Commons,Apache,Recipes for [Apache Commons IO](https://commons.apache.org/proper/commons-io/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.io.ApacheIOUtilsUseExplicitCharset,Use IOUtils method that include their charset encoding,"Use `IOUtils` method invocations that include the charset encoding instead of using the deprecated versions that do not include a charset encoding. (e.g. converts `IOUtils.readLines(inputStream)` to `IOUtils.readLines(inputStream, StandardCharsets.UTF_8)`.",1,Commons IO,Commons,Apache,Recipes for [Apache Commons IO](https://commons.apache.org/proper/commons-io/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks.,"[{""name"":""encoding"",""type"":""String"",""displayName"":""Default encoding"",""description"":""The default encoding to use, must be a standard charset."",""example"":""UTF_8""}]" +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.io.ApacheCommonsFileUtilsRecipes$WriteStringToFileRecipe,"Replace `FileUtils.writeStringToFile(File, String)` with JDK provided API","Replace Apache Commons `FileUtils.writeStringToFile(File file, String data)` with JDK provided API.",1,Commons IO,Commons,Apache,Recipes for [Apache Commons IO](https://commons.apache.org/proper/commons-io/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.io.ApacheCommonsFileUtilsRecipes$WriteAppendWithCharsetRecipe,"Replace `FileUtils.write(File, CharSequence, boolean)` with `FileUtils.write(File, CharSequence, StandardCharsets.UTF_8, boolean)`","Replace deprecated `FileUtils.write(File, CharSequence, boolean)` with `FileUtils.write(File, CharSequence, StandardCharsets.UTF_8, boolean)`.",1,Commons IO,Commons,Apache,Recipes for [Apache Commons IO](https://commons.apache.org/proper/commons-io/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.io.RelocateApacheCommonsIo,Relocate `org.apache.commons:commons-io` to `commons-io:commons-io`,The deployment of `org.apache.commons:commons-io` [was a publishing mistake around 2012](https://issues.sonatype.org/browse/MVNCENTRAL-244) which was corrected by changing the deployment GAV to be located under `commons-io:commons-io`.,2,Commons IO,Commons,Apache,Recipes for [Apache Commons IO](https://commons.apache.org/proper/commons-io/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.io.UseSystemLineSeparator,Prefer `System.lineSeparator()`,Prefer the Java standard library's `System.lineSeparator()` over third-party usage of apache's `IOUtils.LINE_SEPARATOR`.,2,Commons IO,Commons,Apache,Recipes for [Apache Commons IO](https://commons.apache.org/proper/commons-io/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.io.UseStandardCharsets,Prefer `java.nio.charset.StandardCharsets`,Prefer the Java standard library's `java.nio.charset.StandardCharsets` over third-party usage of apache's `org.apache.commons.io.Charsets`.,7,Commons IO,Commons,Apache,Recipes for [Apache Commons IO](https://commons.apache.org/proper/commons-io/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes,`ApacheCommonsStringUtils` Refaster recipes,Refaster template recipes for `org.openrewrite.apache.commons.lang.ApacheCommonsStringUtils`.,20,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$AbbreviateRecipe,"Replace `StringUtils.abbreviate(String, int)` with JDK provided API","Replace Apache Commons `StringUtils.abbreviate(String str, int maxWidth)` with JDK provided API.",1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$CapitalizeRecipe,Replace `StringUtils.capitalize(String)` with JDK provided API,Replace Apache Commons `StringUtils.capitalize(String str)` with JDK provided API.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$DefaultStringFallbackRecipe,"Replace `StringUtils.defaultString(String, String)` with JDK provided API","Replace Apache Commons `StringUtils.defaultString(String str, String nullDefault)` with JDK provided API.",1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$DefaultStringRecipe,Replace `StringUtils.defaultString(String)` with JDK provided API,Replace Apache Commons `StringUtils.defaultString(String str)` with JDK provided API.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$DeleteWhitespaceRecipe,Replace `StringUtils.deleteWhitespace(String)` with JDK provided API,Replace Apache Commons `StringUtils.deleteWhitespace(String str)` with JDK provided API.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$EqualsIgnoreCaseRecipe,"Replace `StringUtils.equalsIgnoreCase(CharSequence, CharSequence)` with JDK provided API","Replace Apache Commons `StringUtils.equalsIgnoreCase(CharSequence cs1, CharSequence cs2)` with JDK provided API.",1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$EqualsRecipe,"Replace `StringUtils.equals(CharSequence, CharSequence)` with JDK provided API","Replace Apache Commons `StringUtils.equals(CharSequence cs1, CharSequence cs2)` with JDK provided API.",1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$LowercaseRecipe,Replace `StringUtils.lowerCase(String)` with JDK provided API,Replace Apache Commons `StringUtils.lowerCase(String str)` with JDK provided API.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$RemoveEndRecipe,"Replace `StringUtils.removeEnd(String, String)` with JDK provided API","Replace Apache Commons `StringUtils.removeEnd(String str, String remove)` with JDK provided API.",1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$RemoveRedundantNullCheckWithIsNotBlankRecipe,Remove redundant null check when using `StringUtils.isNotBlank(String)`,Remove redundant null check when using `StringUtils.isNotBlank(String)` as it already handles null values.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$ReplaceRecipe,"Replace `StringUtils.replace(String, String, String)` with JDK provided API","Replace Apache Commons `StringUtils.replace(String text, String searchString, String replacement)` with JDK provided API.",1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.DefaultIfBlankToJdk,"Replace StringUtils#defaultIfBlank(String, String) with JDK equivalent","Replace `StringUtils#defaultIfBlank(s, fallback)` with `s == null || s.isBlank() ? fallback : s`.",1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$ReverseRecipe,Replace `StringUtils.reverse(String)` with JDK provided API,Replace Apache Commons `StringUtils.reverse(String str)` with JDK provided API.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$SplitRecipe,Replace `StringUtils.split(String)` with JDK provided API,Replace Apache Commons `StringUtils.split(String str)` with JDK provided API.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$StringJoinSeparatorIterableCharSequenceRecipe,"Replace `StringUtils.join(Iterable, String)` with JDK provided API","Replace Apache Commons `StringUtils.join(Iterable iterable, String separator)` with JDK provided API.",1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$ReplaceRecipe,"Replace `StringUtils.replace(String, String, String)` with JDK provided API","Replace Apache Commons `StringUtils.replace(String text, String searchString, String replacement)` with JDK provided API.",1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$DeleteWhitespaceRecipe,Replace `StringUtils.deleteWhitespace(String)` with JDK provided API,Replace Apache Commons `StringUtils.deleteWhitespace(String str)` with JDK provided API.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$StripRecipe,Replace `StringUtils.strip(String)` with JDK provided API,Replace Apache Commons `StringUtils.strip(String str)` with JDK provided API.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$TrimRecipe,Replace `StringUtils.trim(String)` with JDK provided API,Replace Apache Commons `StringUtils.trim(String str)` with JDK provided API.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$LowercaseRecipe,Replace `StringUtils.lowerCase(String)` with JDK provided API,Replace Apache Commons `StringUtils.lowerCase(String str)` with JDK provided API.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$StringJoinSeparatorIterableCharSequenceRecipe,"Replace `StringUtils.join(Iterable, String)` with JDK provided API","Replace Apache Commons `StringUtils.join(Iterable iterable, String separator)` with JDK provided API.",1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.IsBlankToJdk,Replace any StringUtils#isBlank(String) and #isNotBlank(String),Replace any `StringUtils#isBlank(String)` and `#isNotBlank(String)` with `s == null || s.isBlank()` and `s != null && !s.isBlank()`.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$RemoveRedundantNullCheckWithIsNotBlankRecipe,Remove redundant null check when using `StringUtils.isNotBlank(String)`,Remove redundant null check when using `StringUtils.isNotBlank(String)` as it already handles null values.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$EqualsIgnoreCaseRecipe,"Replace `StringUtils.equalsIgnoreCase(CharSequence, CharSequence)` with JDK provided API","Replace Apache Commons `StringUtils.equalsIgnoreCase(CharSequence cs1, CharSequence cs2)` with JDK provided API.",1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$SplitRecipe,Replace `StringUtils.split(String)` with JDK provided API,Replace Apache Commons `StringUtils.split(String str)` with JDK provided API.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$TrimToEmptyRecipe,Replace `StringUtils.trimToEmpty(String)` with JDK provided API,Replace Apache Commons `StringUtils.trimToEmpty(String str)` with JDK provided API.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$TrimToNullRecipe,Replace `StringUtils.trimToNull(String)` with JDK provided API,Replace Apache Commons `StringUtils.trimToNull(String str)` with JDK provided API.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$UppercaseRecipe,Replace `StringUtils.upperCase(String)` with JDK internals,Replace Apache Commons `StringUtils.upperCase(String str)` with JDK internals.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.DefaultIfBlankToJdk,"Replace StringUtils#defaultIfBlank(String, String) with JDK equivalent","Replace `StringUtils#defaultIfBlank(s, fallback)` with `s == null || s.isBlank() ? fallback : s`.",1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.IsBlankToJdk,Replace any StringUtils#isBlank(String) and #isNotBlank(String),Replace any `StringUtils#isBlank(String)` and `#isNotBlank(String)` with `s == null || s.isBlank()` and `s != null && !s.isBlank()`.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$DefaultStringRecipe,Replace `StringUtils.defaultString(String)` with JDK provided API,Replace Apache Commons `StringUtils.defaultString(String str)` with JDK provided API.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.IsNotEmptyToJdk,Replace any StringUtils#isEmpty(String) and #isNotEmpty(String),Replace any `StringUtils#isEmpty(String)` and `#isNotEmpty(String)` with `s == null || s.isEmpty()` and `s != null && !s.isEmpty()`.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$DefaultStringFallbackRecipe,"Replace `StringUtils.defaultString(String, String)` with JDK provided API","Replace Apache Commons `StringUtils.defaultString(String str, String nullDefault)` with JDK provided API.",1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$EqualsRecipe,"Replace `StringUtils.equals(CharSequence, CharSequence)` with JDK provided API","Replace Apache Commons `StringUtils.equals(CharSequence cs1, CharSequence cs2)` with JDK provided API.",1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$TrimToNullRecipe,Replace `StringUtils.trimToNull(String)` with JDK provided API,Replace Apache Commons `StringUtils.trimToNull(String str)` with JDK provided API.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes$CapitalizeRecipe,Replace `StringUtils.capitalize(String)` with JDK provided API,Replace Apache Commons `StringUtils.capitalize(String str)` with JDK provided API.,1,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.ApacheCommonsStringUtilsRecipes,`ApacheCommonsStringUtils` Refaster recipes,Refaster template recipes for `org.openrewrite.apache.commons.lang.ApacheCommonsStringUtils`.,20,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.UpgradeApacheCommonsLang_2_3,Migrates to Apache Commons Lang 3.x,"Migrate applications to the latest Apache Commons Lang 3.x release. This recipe modifies application's build files, and changes the package as per [the migration release notes](https://commons.apache.org/proper/commons-lang/article3_0.html).",27,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.lang.WordUtilsToCommonsText,Migrate `WordUtils` to Apache Commons Text,Migrate `org.apache.commons.lang.WordUtils` to `org.apache.commons.text.WordUtils` and add the Commons Text dependency.,5,Commons Lang,Commons,Apache,Recipes for [Apache Commons Lang](https://commons.apache.org/proper/commons-lang/) upgrades and migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.commons.collections.UpgradeApacheCommonsCollections_3_4,Migrates to Apache Commons Collections 4.x,"Migrate applications to the latest Apache Commons Collections 4.x release. This recipe modifies application's build files, make changes to deprecated/preferred APIs, and migrates configuration settings that have changes between versions.",7,Commons Collections,Commons,Apache,Recipes for [Apache Commons Collections](https://commons.apache.org/proper/commons-collections/) migrations.,,Recipes to perform [Apache](https://apache.org/) project migration tasks., @@ -52,21 +52,22 @@ References: - [IBM Support Pages](https://www.ibm.com/support/pages/im-using-apache-httpclient-make-outbound-call-my-web-application-running-websphere-application-server-traditional-and-im-getting-ssl-handshake-error-how-can-i-debug).",1,,HttpClient 4,Apache,,Recipes for migrating from [Apache HttpClient 4.x](https://hc.apache.org/httpcomponents-client-4.5.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient4.UpgradeApacheHttpClient_4_5,Migrates to ApacheHttpClient 4.5.x,"Migrate applications to the latest Apache HttpClient 4.5.x release. This recipe modifies application's build files, make changes to deprecated/preferred APIs, and migrates configuration settings that have changes between versions.",7,,HttpClient 4,Apache,,Recipes for migrating from [Apache HttpClient 4.x](https://hc.apache.org/httpcomponents-client-4.5.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient4.MappingDeprecatedClasses,Maps deprecated classes from Apache HttpClient 4.5.x to suggested replacements,Uses new classes/methods instead of the deprecated ones.,5,,HttpClient 4,Apache,,Recipes for migrating from [Apache HttpClient 4.x](https://hc.apache.org/httpcomponents-client-4.5.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.AddTimeUnitArgument,Adds a TimeUnit argument to the matched method invocations,"In Apache Http Client 5.x migration, an extra TimeUnit argument is required in the timeout and duration methods. Previously in 4.x, all these methods were implicitly having the timeout or duration expressed in milliseconds, but in 5.x the unit of the timeout or duration is required. So, by default this recipe adds `TimeUnit.MILLISECONDS`, it is possible to specify this as a parameter. Since all affected methods of the Apache Http Client 5.x migration only have one integer/long argument, the recipe applies with matched method invocations of exactly one parameter.",1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks.,"[{""name"":""methodPattern"",""type"":""String"",""displayName"":""Method pattern"",""description"":""A method pattern that is used to find matching method invocations."",""example"":""org.apache.http.client.config.RequestConfig.Builder setConnectionRequestTimeout(int)"",""required"":true},{""name"":""timeUnit"",""type"":""TimeUnit"",""displayName"":""Time unit"",""description"":""The TimeUnit enum value we want to add to the method invocation. Defaults to `MILLISECONDS`."",""example"":""MILLISECONDS""}]" -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.ChangeArgumentToTimeValue,Changes an argument (or pair of arguments) to a `TimeValue` for matched method invocations,"In Apache Http Client 5.x migration, some methods that previously took a single `long` argument, or a pair of arguments of type `long` and `TimeUnit` respectively, have changed to take a `TimeValue`. Previously in 4.x, all these single `long` argument methods were implicitly having the value expressed in milliseconds. By default this recipe uses `TimeUnit.MILLISECONDS` for the `TimeUnit` when creating a `TimeValue`. It is possible to specify this as a option. The `timeUnit` option will be ignored for cases matching `*(long, TimeUnit).",1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks.,"[{""name"":""methodPattern"",""type"":""String"",""displayName"":""Method pattern"",""description"":""A method pattern that is used to find matching method invocations."",""example"":""org.apache.http.impl.nio.reactor.IOReactorConfig.Builder setSelectInterval(long)"",""required"":true},{""name"":""timeUnit"",""type"":""TimeUnit"",""displayName"":""Time unit"",""description"":""The TimeUnit enum value we want to use to turn the original value into a TimeValue. Defaults to `MILLISECONDS`."",""example"":""MILLISECONDS""}]" +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.NewRequestLine,Replaces deprecated `HttpRequestBase::getRequestLine()`,"`HttpRequestBase::getStatusLine()` was deprecated in 4.x, so we replace it with `new RequestLine(HttpRequest)`. Ideally we will try to simply method chains for `getMethod`, `getUri` and `getProtocolVersion`, but there are some scenarios where `RequestLine` object is assigned or used directly, and we need to instantiate the object.",1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.InputBufferReadAddOffsetAndLengthArguments,Adds offset and length arguments to the read method of SharedInputBuffer,"In Apache Http Client 5.x migration, the shortened form of the `read(byte[])` has been removed.",1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.MigrateAuthScope,Replaces `AuthScope.ANY`,"Replace removed constant `org.apache.http.auth.AuthScope.AuthScope.ANY` with `new org.apache.hc.client5.http.auth.AuthScope(null, -1)`.",1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.MigratePoolingNHttpClientConnectionManager,Migrate `PoolingNHttpClientConnectionManager` to `PoolingAsyncClientConnectionManager`,Migrates `PoolingNHttpClientConnectionManager` from Apache HttpAsyncClient 4.x to `PoolingAsyncClientConnectionManager` in HttpClient 5.x using the builder pattern.,1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.AddTimeUnitArgument,Adds a TimeUnit argument to the matched method invocations,"In Apache Http Client 5.x migration, an extra TimeUnit argument is required in the timeout and duration methods. Previously in 4.x, all these methods were implicitly having the timeout or duration expressed in milliseconds, but in 5.x the unit of the timeout or duration is required. So, by default this recipe adds `TimeUnit.MILLISECONDS`, it is possible to specify this as a parameter. Since all affected methods of the Apache Http Client 5.x migration only have one integer/long argument, the recipe applies with matched method invocations of exactly one parameter.",1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks.,"[{""name"":""methodPattern"",""type"":""String"",""displayName"":""Method pattern"",""description"":""A method pattern that is used to find matching method invocations."",""example"":""org.apache.http.client.config.RequestConfig.Builder setConnectionRequestTimeout(int)"",""required"":true},{""name"":""timeUnit"",""type"":""TimeUnit"",""displayName"":""Time unit"",""description"":""The TimeUnit enum value we want to add to the method invocation. Defaults to `MILLISECONDS`."",""example"":""MILLISECONDS"",""valid"":[""NANOSECONDS"",""MICROSECONDS"",""MILLISECONDS"",""SECONDS"",""MINUTES"",""HOURS"",""DAYS""]}]" maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.MigrateRequestConfig,Migrate `RequestConfig` to httpclient5,Migrate `RequestConfig` to httpclient5.,1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.MigrateSSLConnectionSocketFactory,Migrate deprecated `SSLConnectionSocketFactory` to `DefaultClientTlsStrategy`,Migrates usage of the deprecated `org.apache.http.conn.ssl.SSLConnectionSocketFactory` to `org.apache.hc.client5.http.ssl.DefaultClientTlsStrategy` with proper connection manager setup.,1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.MigrateStringEntityStringCharsetConstructor,"Replace `new StringEntity(String, String)` with `new StringEntity(String, Charset)`","Replace `new StringEntity(String, String)` with `new StringEntity(String, Charset)` to eliminate literal usage for charset parameters.",1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.NewRequestLine,Replaces deprecated `HttpRequestBase::getRequestLine()`,"`HttpRequestBase::getStatusLine()` was deprecated in 4.x, so we replace it with `new RequestLine(HttpRequest)`. Ideally we will try to simply method chains for `getMethod`, `getUri` and `getProtocolVersion`, but there are some scenarios where `RequestLine` object is assigned or used directly, and we need to instantiate the object.",1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.NewStatusLine,Replaces deprecated `HttpResponse::getStatusLine()`,"`HttpResponse::getStatusLine()` was deprecated in 4.x, so we replace it for `new StatusLine(HttpResponse)`. Ideally we will try to simplify method chains for `getStatusCode`, `getProtocolVersion` and `getReasonPhrase`, but there are some scenarios where the `StatusLine` object is assigned or used directly, and we need to instantiate the object.",1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.OutputBufferWriteAddOffsetAndLengthArguments,Adds offset and length arguments to the write method of SharedOutputBuffer,"In Apache Http Client 5.x migration, the shortened form of the `write(byte[])` has been removed.",1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.UsernamePasswordCredentials,Migrate `UsernamePasswordCredentials` to httpclient5,Change the password argument going into `UsernamePasswordCredentials` to be a `char[]`.,1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.MigrateAuthScope,Replaces `AuthScope.ANY`,"Replace removed constant `org.apache.http.auth.AuthScope.AuthScope.ANY` with `new org.apache.hc.client5.http.auth.AuthScope(null, -1)`.",1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.RemoveByteBufferAllocators,Remove ByteBufferAllocator implementations,"In Apache Http Client 5.x migration, both implementations of `ByteBufferAllocator` have been removed. This recipe will remove usage of said classes in favour of direct static calls to `ByteBuffer`.",1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.ChangeArgumentToTimeValue,Changes an argument (or pair of arguments) to a `TimeValue` for matched method invocations,"In Apache Http Client 5.x migration, some methods that previously took a single `long` argument, or a pair of arguments of type `long` and `TimeUnit` respectively, have changed to take a `TimeValue`. Previously in 4.x, all these single `long` argument methods were implicitly having the value expressed in milliseconds. By default this recipe uses `TimeUnit.MILLISECONDS` for the `TimeUnit` when creating a `TimeValue`. It is possible to specify this as a option. The `timeUnit` option will be ignored for cases matching `*(long, TimeUnit).",1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks.,"[{""name"":""methodPattern"",""type"":""String"",""displayName"":""Method pattern"",""description"":""A method pattern that is used to find matching method invocations."",""example"":""org.apache.http.impl.nio.reactor.IOReactorConfig.Builder setSelectInterval(long)"",""required"":true},{""name"":""timeUnit"",""type"":""TimeUnit"",""displayName"":""Time unit"",""description"":""The TimeUnit enum value we want to use to turn the original value into a TimeValue. Defaults to `MILLISECONDS`."",""example"":""MILLISECONDS"",""valid"":[""NANOSECONDS"",""MICROSECONDS"",""MILLISECONDS"",""SECONDS"",""MINUTES"",""HOURS"",""DAYS""]}]" +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.MigratePoolingNHttpClientConnectionManager,Migrate `PoolingNHttpClientConnectionManager` to `PoolingAsyncClientConnectionManager`,Migrates `PoolingNHttpClientConnectionManager` from Apache HttpAsyncClient 4.x to `PoolingAsyncClientConnectionManager` in HttpClient 5.x using the builder pattern.,1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.UsePoolingAsyncClientConnectionManagerBuilder,Use `PoolingAsyncClientConnectionManagerBuilder` for configuration,Moves method calls that exist on both `PoolingAsyncClientConnectionManager` and `PoolingAsyncClientConnectionManagerBuilder` into the builder chain.,1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.UsernamePasswordCredentials,Migrate `UsernamePasswordCredentials` to httpclient5,Change the password argument going into `UsernamePasswordCredentials` to be a `char[]`.,1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.UpgradeApacheHttpClient_5,Migrate to ApacheHttpClient 5.x,"Migrate applications to the latest Apache HttpClient 5.x release. This recipe will modify an application's build files, make changes to deprecated/preferred APIs, and migrate configuration settings that have changes between versions.",247,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.OutputBufferWriteAddOffsetAndLengthArguments,Adds offset and length arguments to the write method of SharedOutputBuffer,"In Apache Http Client 5.x migration, the shortened form of the `write(byte[])` has been removed.",1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.MigrateAuthSchemeCredentials,Migrate `AuthScheme` credential handling,"Rewrites `AuthExchange#update(BasicScheme, Credentials)` to `BasicScheme#initPreemptive(Credentials)` followed by `AuthExchange#select(AuthScheme)`. Unwraps leftover `AuthOption#getAuthScheme()` calls (now on `AuthScheme` after the type rename) to the receiver itself. Other `update`/`setCredentials`/`getCredentials` call sites are flagged separately by `AddCommentToMethodInvocations`.",1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.NewStatusLine,Replaces deprecated `HttpResponse::getStatusLine()`,"`HttpResponse::getStatusLine()` was deprecated in 4.x, so we replace it for `new StatusLine(HttpResponse)`. Ideally we will try to simplify method chains for `getStatusCode`, `getProtocolVersion` and `getReasonPhrase`, but there are some scenarios where the `StatusLine` object is assigned or used directly, and we need to instantiate the object.",1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.MigrateStringEntityStringCharsetConstructor,"Replace `new StringEntity(String, String)` with `new StringEntity(String, Charset)`","Replace `new StringEntity(String, String)` with `new StringEntity(String, Charset)` to eliminate literal usage for charset parameters.",1,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.UpgradeApacheHttpClient_5,Migrate to ApacheHttpClient 5.x,"Migrate applications to the latest Apache HttpClient 5.x release. This recipe will modify an application's build files, make changes to deprecated/preferred APIs, and migrate configuration settings that have changes between versions.",257,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.UpgradeApacheHttpClientDependencies,Migrate from org.apache.httpcomponents to ApacheHttpClient 5.x dependencies,Adopt `org.apache.httpcomponents.client5:httpclient5` from `org.apache.httpcomponents`.,6,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.UpgradeApacheHttpCoreNioDependencies,Migrate from httpcore-nio to ApacheHttpClient 5.x core dependency,Adopt `org.apache.httpcomponents.core5:httpcore5` from `org.apache.httpcomponents:httpcore-nio`.,3,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.UpgradeApacheHttpCore_5_NioInputBuffers,Migrate Apache HttpCore Nio Input Buffer classes to Apache HttpCore 5.x,Mapping of specifically `*InputBuffer` classes of Apache HttpCore 5.x from Apache HttpCore Nio 4.4.x.,13,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., @@ -79,45 +80,46 @@ maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.U maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.StatusLine,Migrate to ApacheHttpClient 5.x deprecated methods from 4.x,Migrates deprecated methods to their equivalent ones in 5.x.,6,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.CredentialsStoreSetCredentials,Migrate `setCredentials` to ApacheHttpClient 5.x `CredentialsStore`,Migrates `BasicCredentialsProvider` methods`setCredentials` to the new `CredentialsStore` interface.,2,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.CredentialsStoreClear,Migrate `clear` to ApacheHttpClient 5.x `CredentialsStore`,Migrates `BasicCredentialsProvider` methods`clear` to the new `CredentialsStore` interface.,2,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.MigrateAuthState,Migrate `AuthState` to `AuthExchange`,"Migrate Apache HttpClient 4.x `AuthState` and related types to the HttpClient 5.x `AuthExchange` API, including the `AuthProtocolState` enum, `AuthOption` queue elements, and credential-handling call sites.",10,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.httpclient5.UpgradeApacheHttpClient_5_AsyncClientClassMapping,Migrate Apache HttpAsyncClient 4.x classes to HttpClient 5.x,Migrates classes from Apache HttpAsyncClient 4.x `httpasyncclient` to their equivalents in HttpClient 5.x.,11,,HttpClient 5,Apache,,Recipes for migrating to [Apache HttpClient 5.x](https://hc.apache.org/httpcomponents-client-5.4.x/).,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$StripRecipe,Replace `StringUtils.strip(String)` with JDK provided API,Replace Maven Shared `StringUtils.strip(String str)` with JDK provided API.,1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$DefaultStringRecipe,Replace `StringUtils.defaultString(Object)` with JDK provided API,Replace Maven Shared `StringUtils.defaultString(Object obj)` with JDK provided API.,1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes,`MavenSharedStringUtils` Refaster recipes,Refaster template recipes for `org.openrewrite.apache.maven.shared.MavenSharedStringUtils`.,15,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$AbbreviateRecipe,"Replace `StringUtils.abbreviate(String, int)` with JDK provided API","Replace Maven Shared `StringUtils.abbreviate(String str, int maxWidth)` with JDK provided API.",1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$CapitaliseRecipe,Replace `StringUtils.capitalise(String)` with JDK provided API,Replace Maven Shared `StringUtils.capitalise(String str)` with JDK provided API.,1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$UppercaseRecipe,Replace `StringUtils.upperCase(String)` with JDK provided API,Replace Maven Shared `StringUtils.upperCase(String str)` with JDK provided API.,1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$DefaultStringFallbackRecipe,"Replace `StringUtils.defaultString(Object, String)` with JDK provided API","Replace Maven Shared `StringUtils.defaultString(Object obj, String nullDefault)` with JDK provided API.",1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$DefaultStringRecipe,Replace `StringUtils.defaultString(Object)` with JDK provided API,Replace Maven Shared `StringUtils.defaultString(Object obj)` with JDK provided API.,1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$DeleteWhitespaceRecipe,Replace `StringUtils.deleteWhitespace(String)` with JDK provided API,Replace Maven Shared `StringUtils.deleteWhitespace(String str)` with JDK provided API.,1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$EqualsIgnoreCaseRecipe,"Replace `StringUtils.equalsIgnoreCase(String, String)` with JDK provided API","Replace Maven Shared `StringUtils.equalsIgnoreCase(String str1, String str2)` with JDK provided API.",1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$EqualsRecipe,"Replace `StringUtils.equals(String, String)` with JDK provided API","Replace Maven Shared `StringUtils.equals(String str1, String str2)` with JDK provided API.",1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$LowercaseRecipe,Replace `StringUtils.lowerCase(String)` with JDK provided API,Replace Maven Shared `StringUtils.lowerCase(String str)` with JDK provided API.,1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$SplitRecipe,Replace `StringUtils.split(String)` with JDK provided API,Replace Maven Shared `StringUtils.split(String str)` with JDK provided API.,1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$AbbreviateRecipe,"Replace `StringUtils.abbreviate(String, int)` with JDK provided API","Replace Maven Shared `StringUtils.abbreviate(String str, int maxWidth)` with JDK provided API.",1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$ReplaceRecipe,"Replace `StringUtils.replace(String, String, String)` with JDK provided API","Replace Maven Shared `StringUtils.replace(String text, String searchString, String replacement)` with JDK provided API.",1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$DeleteWhitespaceRecipe,Replace `StringUtils.deleteWhitespace(String)` with JDK provided API,Replace Maven Shared `StringUtils.deleteWhitespace(String str)` with JDK provided API.,1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$EqualsIgnoreCaseRecipe,"Replace `StringUtils.equalsIgnoreCase(String, String)` with JDK provided API","Replace Maven Shared `StringUtils.equalsIgnoreCase(String str1, String str2)` with JDK provided API.",1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$ReverseRecipe,Replace `StringUtils.reverse(String)` with JDK provided API,Replace Maven Shared `StringUtils.reverse(String str)` with JDK provided API.,1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$SplitRecipe,Replace `StringUtils.split(String)` with JDK provided API,Replace Maven Shared `StringUtils.split(String str)` with JDK provided API.,1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$StripRecipe,Replace `StringUtils.strip(String)` with JDK provided API,Replace Maven Shared `StringUtils.strip(String str)` with JDK provided API.,1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$CapitaliseRecipe,Replace `StringUtils.capitalise(String)` with JDK provided API,Replace Maven Shared `StringUtils.capitalise(String str)` with JDK provided API.,1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$LowercaseRecipe,Replace `StringUtils.lowerCase(String)` with JDK provided API,Replace Maven Shared `StringUtils.lowerCase(String str)` with JDK provided API.,1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$TrimRecipe,Replace `StringUtils.trim(String)` with JDK provided API,Replace Maven Shared `StringUtils.trim(String str)` with JDK provided API.,1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.maven.shared.MavenSharedStringUtilsRecipes$UppercaseRecipe,Replace `StringUtils.upperCase(String)` with JDK provided API,Replace Maven Shared `StringUtils.upperCase(String str)` with JDK provided API.,1,Shared,Maven,Apache,,,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.poi.ReplaceSetBoldweightWithSetBold,Replace `Font.setBoldweight(short)` with `Font.setBold(boolean)`,Replace `Font.setBoldweight(short)` or equivalent with `Font.setBold(boolean)`.,1,,Apache POI,Apache,,Recipes for [Apache POI](https://poi.apache.org/) spreadsheet library.,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.poi.ReplaceSetCellType,Apache POI use `Cell.setCellType(CellType)`,"`Cell.setCellType()` can be configured with either an integer or a the `CellType` enumeration. It is clearer and less error-prone to use the `CellType` enumeration, so this recipe converts all `setCellType()` calls to use it.",1,,Apache POI,Apache,,Recipes for [Apache POI](https://poi.apache.org/) spreadsheet library.,Recipes to perform [Apache](https://apache.org/) project migration tasks., +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.poi.ReplaceSetBoldweightWithSetBold,Replace `Font.setBoldweight(short)` with `Font.setBold(boolean)`,Replace `Font.setBoldweight(short)` or equivalent with `Font.setBold(boolean)`.,1,,Apache POI,Apache,,Recipes for [Apache POI](https://poi.apache.org/) spreadsheet library.,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.poi.UpgradeApachePoi_3_17,Migrates to Apache POI 3.17,Migrates to the last Apache POI 3.x release. This recipe modifies build files and makes changes to deprecated/preferred APIs that have changed between versions.,64,,Apache POI,Apache,,Recipes for [Apache POI](https://poi.apache.org/) spreadsheet library.,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.poi.UpgradeApachePoi_4_1,Migrates to Apache POI 4.1.2,Migrates to the last Apache POI 4.x release. This recipe modifies build files and makes changes to deprecated/preferred APIs that have changed between versions.,72,,Apache POI,Apache,,Recipes for [Apache POI](https://poi.apache.org/) spreadsheet library.,Recipes to perform [Apache](https://apache.org/) project migration tasks., maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.apache.poi.UpgradeApachePoi_5,Migrates to Apache POI 5.x,Migrates to the latest Apache POI 5.x release. This recipe modifies build files to account for artifact renames and upgrades dependency versions. It also chains the 4.1 recipe to handle all prior API migrations.,77,,Apache POI,Apache,,Recipes for [Apache POI](https://poi.apache.org/) spreadsheet library.,Recipes to perform [Apache](https://apache.org/) project migration tasks., -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.AbstractLogEnabledToSlf4j,Migrate from Plexus `AbstractLogEnabled` to SLF4J,Introduce a SLF4J `Logger` field and replace calls to `getLogger()` with calls to the field.,1,,Plexus,Codehaus,,,, -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusFileUtilsRecipes,`PlexusFileUtils` Refaster recipes,Refaster template recipes for `org.openrewrite.codehaus.plexus.PlexusFileUtils`.,5,,Plexus,Codehaus,,,, -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusFileUtilsRecipes$DeleteDirectoryFileRecipe,Replace `FileUtils.deleteDirectory(File)` with JDK provided API,Replace Plexus `FileUtils.deleteDirectory(File directory)` with JDK provided API.,1,,Plexus,Codehaus,,,, -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusFileUtilsRecipes$DeleteDirectoryStringRecipe,Replace `FileUtils.deleteDirectory(String)` with JDK provided API,Replace Plexus `FileUtils.deleteDirectory(String directory)` with JDK provided API.,1,,Plexus,Codehaus,,,, +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$EqualsIgnoreCaseRecipe,"Replace `StringUtils.equalsIgnoreCase(String, String)` with JDK provided API","Replace Plexus `StringUtils.equalsIgnoreCase(String str1, String str2)` with JDK provided API.",1,,Plexus,Codehaus,,,, +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$TrimRecipe,Replace `StringUtils.trim(String)` with JDK provided API,Replace Plexus `StringUtils.trim(String str)` with JDK provided API.,1,,Plexus,Codehaus,,,, maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusFileUtilsRecipes$FileExistsStringRecipe,Replace `FileUtils.fileExists(String)` with JDK provided API,Replace Plexus `FileUtils.fileExists(String fileName)` with JDK provided API.,1,,Plexus,Codehaus,,,, -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusFileUtilsRecipes$GetFileRecipe,Replace `FileUtils.getFile(String)` with JDK provided API,Replace Plexus `FileUtils.getFile(String fileName)` with JDK provided API.,1,,Plexus,Codehaus,,,, -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes,`PlexusStringUtils` Refaster recipes,Refaster template recipes for `org.openrewrite.codehaus.plexus.PlexusStringUtils`.,15,,Plexus,Codehaus,,,, maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$AbbreviateRecipe,"Replace `StringUtils.abbreviate(String, int)` with JDK provided API","Replace Plexus `StringUtils.abbreviate(String str, int maxWidth)` with JDK provided API.",1,,Plexus,Codehaus,,,, -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$CapitaliseRecipe,Replace `StringUtils.capitalise(String)` with JDK provided API,Replace Plexus `StringUtils.capitalise(String str)` with JDK provided API.,1,,Plexus,Codehaus,,,, -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$DefaultStringFallbackRecipe,"Replace `StringUtils.defaultString(Object, String)` with JDK provided API","Replace Plexus `StringUtils.defaultString(Object obj, String nullDefault)` with JDK provided API.",1,,Plexus,Codehaus,,,, -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$DefaultStringRecipe,Replace `StringUtils.defaultString(Object)` with JDK provided API,Replace Plexus `StringUtils.defaultString(Object obj)` with JDK provided API.,1,,Plexus,Codehaus,,,, maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$DeleteWhitespaceRecipe,Replace `StringUtils.deleteWhitespace(String)` with JDK provided API,Replace Plexus `StringUtils.deleteWhitespace(String str)` with JDK provided API.,1,,Plexus,Codehaus,,,, -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$EqualsIgnoreCaseRecipe,"Replace `StringUtils.equalsIgnoreCase(String, String)` with JDK provided API","Replace Plexus `StringUtils.equalsIgnoreCase(String str1, String str2)` with JDK provided API.",1,,Plexus,Codehaus,,,, -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$EqualsRecipe,"Replace `StringUtils.equals(String, String)` with JDK provided API","Replace Plexus `StringUtils.equals(String str1, String str2)` with JDK provided API.",1,,Plexus,Codehaus,,,, -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$LowercaseRecipe,Replace `StringUtils.lowerCase(String)` with JDK provided API,Replace Plexus `StringUtils.lowerCase(String str)` with JDK provided API.,1,,Plexus,Codehaus,,,, +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusFileUtilsRecipes,`PlexusFileUtils` Refaster recipes,Refaster template recipes for `org.openrewrite.codehaus.plexus.PlexusFileUtils`.,5,,Plexus,Codehaus,,,, +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusFileUtilsRecipes$DeleteDirectoryStringRecipe,Replace `FileUtils.deleteDirectory(String)` with JDK provided API,Replace Plexus `FileUtils.deleteDirectory(String directory)` with JDK provided API.,1,,Plexus,Codehaus,,,, maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$ReplaceRecipe,"Replace `StringUtils.replace(String, String, String)` with JDK provided API","Replace Plexus `StringUtils.replace(String text, String searchString, String replacement)` with JDK provided API.",1,,Plexus,Codehaus,,,, -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$ReverseRecipe,Replace `StringUtils.reverse(String)` with JDK provided API,Replace Plexus `StringUtils.reverse(String str)` with JDK provided API.,1,,Plexus,Codehaus,,,, maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$SplitRecipe,Replace `StringUtils.split(String)` with JDK provided API,Replace Plexus `StringUtils.split(String str)` with JDK provided API.,1,,Plexus,Codehaus,,,, -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$StripRecipe,Replace `StringUtils.strip(String)` with JDK provided API,Replace Plexus `StringUtils.strip(String str)` with JDK provided API.,1,,Plexus,Codehaus,,,, -maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$TrimRecipe,Replace `StringUtils.trim(String)` with JDK provided API,Replace Plexus `StringUtils.trim(String str)` with JDK provided API.,1,,Plexus,Codehaus,,,, +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusFileUtilsRecipes$GetFileRecipe,Replace `FileUtils.getFile(String)` with JDK provided API,Replace Plexus `FileUtils.getFile(String fileName)` with JDK provided API.,1,,Plexus,Codehaus,,,, +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$DefaultStringRecipe,Replace `StringUtils.defaultString(Object)` with JDK provided API,Replace Plexus `StringUtils.defaultString(Object obj)` with JDK provided API.,1,,Plexus,Codehaus,,,, +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$ReverseRecipe,Replace `StringUtils.reverse(String)` with JDK provided API,Replace Plexus `StringUtils.reverse(String str)` with JDK provided API.,1,,Plexus,Codehaus,,,, +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$DefaultStringFallbackRecipe,"Replace `StringUtils.defaultString(Object, String)` with JDK provided API","Replace Plexus `StringUtils.defaultString(Object obj, String nullDefault)` with JDK provided API.",1,,Plexus,Codehaus,,,, +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$CapitaliseRecipe,Replace `StringUtils.capitalise(String)` with JDK provided API,Replace Plexus `StringUtils.capitalise(String str)` with JDK provided API.,1,,Plexus,Codehaus,,,, maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$UppercaseRecipe,Replace `StringUtils.upperCase(String)` with JDK provided API,Replace Plexus `StringUtils.upperCase(String str)` with JDK provided API.,1,,Plexus,Codehaus,,,, +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.AbstractLogEnabledToSlf4j,Migrate from Plexus `AbstractLogEnabled` to SLF4J,Introduce a SLF4J `Logger` field and replace calls to `getLogger()` with calls to the field.,1,,Plexus,Codehaus,,,, +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes,`PlexusStringUtils` Refaster recipes,Refaster template recipes for `org.openrewrite.codehaus.plexus.PlexusStringUtils`.,15,,Plexus,Codehaus,,,, +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusFileUtilsRecipes$DeleteDirectoryFileRecipe,Replace `FileUtils.deleteDirectory(File)` with JDK provided API,Replace Plexus `FileUtils.deleteDirectory(File directory)` with JDK provided API.,1,,Plexus,Codehaus,,,, +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$LowercaseRecipe,Replace `StringUtils.lowerCase(String)` with JDK provided API,Replace Plexus `StringUtils.lowerCase(String str)` with JDK provided API.,1,,Plexus,Codehaus,,,, +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$EqualsRecipe,"Replace `StringUtils.equals(String, String)` with JDK provided API","Replace Plexus `StringUtils.equals(String str1, String str2)` with JDK provided API.",1,,Plexus,Codehaus,,,, +maven,org.openrewrite.recipe:rewrite-apache,org.openrewrite.codehaus.plexus.PlexusStringUtilsRecipes$StripRecipe,Replace `StringUtils.strip(String)` with JDK provided API,Replace Plexus `StringUtils.strip(String str)` with JDK provided API.,1,,Plexus,Codehaus,,,, diff --git a/src/test/java/org/openrewrite/apache/httpclient5/MigrateAuthStateTest.java b/src/test/java/org/openrewrite/apache/httpclient5/MigrateAuthStateTest.java new file mode 100644 index 0000000..9086c27 --- /dev/null +++ b/src/test/java/org/openrewrite/apache/httpclient5/MigrateAuthStateTest.java @@ -0,0 +1,229 @@ +/* + * Copyright 2026 the original author or authors. + *

+ * Licensed under the Moderne Source Available License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://docs.moderne.io/licensing/moderne-source-available-license + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.apache.httpclient5; + +import org.junit.jupiter.api.Test; +import org.openrewrite.DocumentExample; +import org.openrewrite.InMemoryExecutionContext; +import org.openrewrite.java.JavaParser; +import org.openrewrite.test.RecipeSpec; +import org.openrewrite.test.RewriteTest; + +import static org.openrewrite.java.Assertions.java; + +class MigrateAuthStateTest implements RewriteTest { + @Override + public void defaults(RecipeSpec spec) { + spec + .parser(JavaParser.fromJavaVersion().classpathFromResources(new InMemoryExecutionContext(), + "httpclient-4", "httpcore-4", "httpclient5", "httpcore5")) + .recipeFromResources("org.openrewrite.apache.httpclient5.UpgradeApacheHttpClient_5"); + } + + @DocumentExample + @Test + void renameTypeAndStateEnumAndMethods() { + rewriteRun( + //language=java + java( + """ + import org.apache.http.auth.AuthScheme; + import org.apache.http.auth.AuthState; + import org.apache.http.auth.AuthProtocolState; + + class A { + void m(AuthState s, AuthScheme scheme) { + s.setAuthScheme(scheme); + s.setState(AuthProtocolState.CHALLENGED); + s.reset(); + } + } + """, + """ + import org.apache.hc.client5.http.auth.AuthExchange.State; + import org.apache.hc.client5.http.auth.AuthScheme; + import org.apache.hc.client5.http.auth.AuthExchange; + + class A { + void m(AuthExchange s, AuthScheme scheme) { + s.select(scheme); + s.setState(AuthExchange.State.CHALLENGED); + s.reset(); + } + } + """ + ) + ); + } + + @Test + void updateWithBasicSchemeRewritesToInitPreemptiveAndSelect() { + rewriteRun( + //language=java + java( + """ + import org.apache.http.auth.AuthState; + import org.apache.http.auth.Credentials; + import org.apache.http.impl.auth.BasicScheme; + + class A { + void m(AuthState s, Credentials creds) { + BasicScheme scheme = new BasicScheme(); + s.update(scheme, creds); + } + } + """, + """ + import org.apache.hc.client5.http.auth.AuthExchange; + import org.apache.hc.client5.http.auth.Credentials; + import org.apache.hc.client5.http.impl.auth.BasicScheme; + + class A { + void m(AuthExchange s, Credentials creds) { + BasicScheme scheme = new BasicScheme(); + scheme.initPreemptive(creds); + s.select(scheme); + } + } + """ + ) + ); + } + + @Test + void updateWithGenericAuthSchemeAddsComment() { + rewriteRun( + //language=java + java( + """ + import org.apache.http.auth.AuthScheme; + import org.apache.http.auth.AuthState; + import org.apache.http.auth.Credentials; + + class A { + void m(AuthState s, AuthScheme scheme, Credentials creds) { + s.update(scheme, creds); + } + } + """, + """ + import org.apache.hc.client5.http.auth.AuthExchange; + import org.apache.hc.client5.http.auth.AuthScheme; + import org.apache.hc.client5.http.auth.Credentials; + + class A { + void m(AuthExchange s, AuthScheme scheme, Credentials creds) { + /* HttpClient 5: credentials must be registered with a CredentialsProvider, not on AuthScheme. */ + s.update(scheme, creds); + } + } + """ + ) + ); + } + + @Test + void setCredentialsAddsComment() { + rewriteRun( + //language=java + java( + """ + import org.apache.http.auth.AuthState; + import org.apache.http.auth.Credentials; + + class A { + void m(AuthState s, Credentials creds) { + s.setCredentials(creds); + } + } + """, + """ + import org.apache.hc.client5.http.auth.AuthExchange; + import org.apache.hc.client5.http.auth.Credentials; + + class A { + void m(AuthExchange s, Credentials creds) { + /* HttpClient 5: credentials must be registered with a CredentialsProvider, not on AuthScheme. */ + s.setCredentials(creds); + } + } + """ + ) + ); + } + + @Test + void authOptionRenamedAndGetAuthSchemeUnwrapped() { + rewriteRun( + //language=java + java( + """ + import org.apache.http.auth.AuthOption; + + import java.util.Queue; + + class A { + Object process(Queue options) { + AuthOption opt = options.peek(); + return opt.getAuthScheme(); + } + } + """, + """ + import org.apache.hc.client5.http.auth.AuthScheme; + + import java.util.Queue; + + class A { + Object process(Queue options) { + AuthScheme opt = options.peek(); + return opt; + } + } + """ + ) + ); + } + + @Test + void getCredentialsAddsComment() { + rewriteRun( + //language=java + java( + """ + import org.apache.http.auth.AuthOption; + import org.apache.http.auth.Credentials; + + class A { + Credentials creds(AuthOption opt) { + return opt.getCredentials(); + } + } + """, + """ + import org.apache.hc.client5.http.auth.AuthScheme; + import org.apache.hc.client5.http.auth.Credentials; + + class A { + Credentials creds(AuthScheme opt) { + return /* HttpClient 5: AuthScheme.getCredentials() is gone; credentials live on CredentialsProvider. */ opt.getCredentials(); + } + } + """ + ) + ); + } +}