Saravanakumar Selvaraj created CAMEL-27390:
----------------------------------------------

             Summary: camel-package-maven-plugin: on Windows the generated 
ModelWriter of camel-xml-io writes onFallback before the outputs of the circuit 
breaker
                 Key: CAMEL-27390
                 URL: https://issues.apache.org/jira/browse/CAMEL-27390
             Project: Camel
          Issue Type: Bug
    Affects Versions: 4.23.0
            Reporter: Saravanakumar Selvaraj


A full build on Windows changes 
core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java, 
although no source changed. It happens when the working tree has LF line ends, 
which Git for Windows gives with core.autocrlf=input or false.

What differs from the committed file:

- doWriteCircuitBreakerDefinition writes the onFallback element before the 
outputs. The committed file writes it after them, as CAMEL-23014 asked.
- The file ends with a newline. The committed file does not.

The cause is ModelWriterGeneratorMojo.postGenerateWriter, which CAMEL-23014 
added in 4.19.0. It moves the onFallback line below the next line of the 
generated source:

- It splits the source with System.lineSeparator(), swaps the two lines, and 
joins them with System.lineSeparator().
- The source comes from the template model-writer.vm and has the line ends of 
that file, which are LF.
- On Windows the separator is CRLF, so split returns the whole source as one 
line. The method then finds no line that starts with 
doWriteElement("onFallback", and it swaps nothing.
- On Linux and macOS, split also drops the empty line at the end. That is why 
the committed file has no final newline.

Effect:

- On such a checkout, ModelWriter.java shows up as modified after each full 
build.
- A Camel that is built there dumps a circuit breaker to XML with onFallback 
before its steps.

Proposed change: postGenerateWriter splits at each line break, LF or CRLF, and 
joins with LF. The generated file is then the same on every platform, and it 
stays as it is on Linux and macOS.

Seen with Java 21 and Maven 3.9.14, after mvn clean install -Dquickly 
-DskipTests in the root folder.

_Claude Code on behalf of saravanakumar1987_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to