Croway commented on code in PR #127:
URL:
https://github.com/apache/camel-upgrade-recipes/pull/127#discussion_r3853011585
##########
camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel418_3/RenameHeaderPrefixInXmlDsl.java:
##########
@@ -69,7 +71,8 @@ public String getDescription() {
@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
- return new XmlHeaderPrefixVisitor(oldPrefix, newPrefix);
+ return Preconditions.check(RecipesUtil.camelXmlDslPrecondition(),
Review Comment:
Confirmed and fixed in f3e0356 — thank you, this was a genuine regression
and my tests would not have caught it.
I reproduced it before changing anything: a `<beans
xmlns="...springframework...">` root wrapping `<camelContext
xmlns="http://camel.apache.org/schema/spring">` was skipped by every gated
recipe, so the header rename silently did nothing.
`isCamelXmlDsl` now works the other way round. A Camel namespace or a
`camelContext`/`routeContext` element is conclusive **wherever it sits in the
document**, checked by recursing through the tree, which covers the `<beans>`
and `<blueprint>` wrappers. The Spring beans namespace only rules a document
out when no Camel marker is found anywhere, which still keeps a pure Spring
bean file out.
Positive tests added for the Spring layout, so the gate cannot silently
narrow again.
One consequence worth flagging, since it was not in your list. Accepting
these documents also makes files like camel-kamelet-main's `spring-camel1.xml`
eligible — a `<camel>` root carrying Spring bean definitions alongside the
routes. With the wider gate, `XmlDsl46Recipe` started rewriting those into
`<bean><properties><property/></properties></bean>`, i.e. the exact corruption
this whole thread is about, just reached from the other direction:
```diff
<camel>
<bean id="bean1" class="org.apache.camel.main.app.Bean1">
- <property name="bean" ref="bean2"/>
+ <properties>
+ <property name="bean" ref="bean2"/>
+ </properties>
</bean>
</camel>
```
A Camel bean declares its class with `type=` where a Spring bean uses
`class=`, so `XmlDsl46Recipe` now converts only beans carrying `type`.
`CamelUpdate46Test` still passes unchanged, and there is a new negative test
for the Spring-style bean. Without that, widening the precondition as you asked
would have introduced a corruption bug.
--
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]