Croway opened a new issue, #107:
URL: https://github.com/apache/camel-upgrade-recipes/issues/107
## Description
The Camel 4.17 migration recipe renames **all** overloads of `transform()`
to `transformDataType()`, but only the DataType overloads were actually renamed
in Camel 4.17. The expression-based and no-arg `transform()` methods are
unchanged.
## Root Cause
In `camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.17.yaml`
(lines 31-34):
```yaml
- org.openrewrite.java.ChangeMethodName:
methodPattern: "org.apache.camel.model.ProcessorDefinition#transform(..)"
newMethodName: "transformDataType"
matchOverrides: true
```
The `(..)` wildcard matches **all** overloads of `transform()`, including:
- `transform()` — no-arg, returns `ExpressionClause` for fluent chaining
like `.transform().simple("...")` — **should NOT be renamed**
- `transform(Expression)` — expression-based transform — **should NOT be
renamed**
- `transform(DataType)` — **should be renamed**
- `transform(DataType, DataType)` — **should be renamed**
## Reproduction
1. Take any Camel Spring Boot project using `transform().simple(...)` (e.g.,
the `pojo` example in `apache/camel-spring-boot-examples` at tag `4.4.0`)
2. Run the `CamelSpringBootMigrationRecipe`
3. Observe that `transform().simple("${random(0,200)}")` is incorrectly
changed to `transformDataType().simple("${random(0,200)}")`
## Expected behavior
Only the DataType overloads should be renamed. The method patterns should be:
```yaml
- org.openrewrite.java.ChangeMethodName:
methodPattern: "org.apache.camel.model.ProcessorDefinition
transform(org.apache.camel.spi.DataType)"
newMethodName: "transformDataType"
matchOverrides: true
- org.openrewrite.java.ChangeMethodName:
methodPattern: "org.apache.camel.model.ProcessorDefinition
transform(org.apache.camel.spi.DataType, org.apache.camel.spi.DataType)"
newMethodName: "transformDataType"
matchOverrides: true
```
## Note
The YAML DSL counterpart (`YamlTransform417Recipe.java`) is correctly
implemented — it only renames when the child entry contains `toType`. The Java
recipe lacks this equivalent guard.
The existing test in `CamelUpdate417Test.java` only tests `transform(new
DataType("myDataType"))` (which is correct to rename) but does not test the
false-positive case of `transform().simple(...)`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]