[ 
https://issues.apache.org/jira/browse/CAMEL-27401?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen resolved CAMEL-27401.
---------------------------------
    Resolution: Fixed

Fixed by https://github.com/apache/camel/pull/30621 (merged to main for 4.24.0).

_Claude Code on behalf of davsclaus_

> camel-groovy: the index of a script validation error depends on the line 
> separator of the platform
> --------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27401
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27401
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-groovy
>    Affects Versions: 4.23.0
>            Reporter: Saravanakumar Selvaraj
>            Assignee: Saravanakumar Selvaraj
>            Priority: Minor
>             Fix For: 4.24.0
>
>
> Found on Windows. testValidateGroovyLanguage of CamelCatalogTest in 
> catalog/camel-catalog fails there: it expects the index 23 and gets 24.
> GroovyValidationException.getIndex computes the position of a syntax error in 
> the script. For each line before the line of the error, it adds the length of 
> the line and System.lineSeparator().length(). So it counts the line break of 
> the platform and not the line break that the script has.
> - On Windows, a script with LF line ends gets an index one too high for each 
> earlier line.
> - On Linux and macOS, a script with CRLF line ends gets an index one too low 
> for each earlier line.
> The script of the test is a Java text block, so it has LF line ends on every 
> platform. Its syntax error is in line 2, column 11, and line 1 has 12 
> characters. So the offset of the error is 12 + 1 + 10 = 23. On Windows the 
> method returns 12 + 2 + 10 = 24.
> CamelCatalog.validateLanguageExpression returns this value as the index of 
> the LanguageValidationResult for the language groovy.
> Proposed change: getIndex finds the start of the line of the error in the 
> script itself. It then counts the line breaks that the script has, and the 
> index is the same on every platform.
> Seen on Windows with Java 21, in a run of CamelCatalogTest. The tag 
> camel-4.23.0 has the same method and the same test.
> _Claude Code on behalf of saravanakumar1987_



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

Reply via email to