Changes an argument (or pair of arguments) to a TimeValue for matched method invocations
org.openrewrite.apache.httpclient5.ChangeArgumentToTimeValueArtifactorg.openrewrite.recipe:rewrite-apacheIn 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).
Add to your build
~/.gradle/gradle.properties
codeGenomeUsername=you@example.com
codeGenomeToken=YOUR_DOWNLOAD_TOKEN
build.gradle.kts
plugins {
id("org.openrewrite.rewrite") version("latest.release")
}
rewrite {
activeRecipe("org.openrewrite.apache.httpclient5.ChangeArgumentToTimeValue")
}
repositories {
mavenCentral()
maven {
url = uri("https://artifacts.codegenomeproject.org/maven")
credentials {
username = providers.gradleProperty("codeGenomeUsername").get()
password = providers.gradleProperty("codeGenomeToken").get()
}
}
}
dependencies {
rewrite("org.openrewrite.recipe:rewrite-apache:2.33.0")
}
Then run
./gradlew rewriteRunThis recipe has required options, which a build sets in a rewrite.yml recipe that you activate instead.
Usage
You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.apache.httpclient5.ChangeArgumentToTimeValue --recipe-option "methodPattern=org.apache.http.impl.nio.reactor.IOReactorConfig.Builder setSelectInterval(long)"If the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-apache:RELEASEOptions
| Name | Type | Description |
|---|---|---|
methodPatternrequired | String | A method pattern that is used to find matching method invocations. e.g. org.apache.http.impl.nio.reactor.IOReactorConfig.Builder setSelectInterval(long) |
timeUnit | TimeUnit | The TimeUnit enum value we want to use to turn the original value into a TimeValue. Defaults to MILLISECONDS.e.g. MILLISECONDS |
Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats