Adds a TimeUnit argument to the matched method invocations
Recipe ID
org.openrewrite.apache.httpclient5.AddTimeUnitArgumentArtifact
org.openrewrite.recipe:rewrite-apacheIn 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.
Usage
You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.apache.httpclient5.AddTimeUnitArgument --recipe-option "methodPattern=org.apache.http.client.config.RequestConfig.Builder setConnectionRequestTimeout(int)"If the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-apache:2.29.0Options
| Name | Type | Description |
|---|---|---|
methodPatternrequired | String | A method pattern that is used to find matching method invocations. e.g. org.apache.http.client.config.RequestConfig.Builder setConnectionRequestTimeout(int) |
timeUnit | TimeUnit | The TimeUnit enum value we want to add to the method invocation. 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