← All recipes
Moderne licensed

Changes an argument (or pair of arguments) to a TimeValue for matched method invocations

Recipe IDorg.openrewrite.apache.httpclient5.ChangeArgumentToTimeValue
Artifactorg.openrewrite.recipe:rewrite-apache

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).

Single recipeMSAL

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:2.29.0

Options

NameTypeDescription
methodPatternrequiredStringA method pattern that is used to find matching method invocations.
e.g. org.apache.http.impl.nio.reactor.IOReactorConfig.Builder setSelectInterval(long)
timeUnitTimeUnitThe 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