davsclaus opened a new pull request, #29814: URL: https://github.com/apache/camel/pull/29814
## Summary Items 3 and 4 of [CAMEL-26912](https://issues.apache.org/jira/browse/CAMEL-26912): **camel export corrupted the application.properties of the exported project.** The export reads the application.properties with `Properties.load`, which resolves the escapes, and wrote each property as a raw `key=value` line in UTF-8: | application.properties | exported, before | read back, before | |---|---|---| | `path=C:\\temp\\new` | `path=C:\temp\new` | `C:` TAB `emp` NEWLINE `ew` | | `regex=^\\d+$` | `regex=^\d+$` | `^d+$` | | `my.key\ with\ space=1` | `my.key with space=1` | key `my.key`, value `with space=1` | | `greeting=Hej æøå` (UTF-8) | `greeting=Hej æøå` (UTF-8) | double encoded | ### Fix - `ExportHelper.propertyLine(key, value)` escapes a property as a properties file needs it: a backslash, tab, new line and the other control characters, a leading space of the value, and a space, `=`, `:`, `#` and `!` of the key. Other characters of a value are written as they are, so `jdbc:mysql://localhost` stays readable (`Properties.store` would write `jdbc\:mysql\://localhost`). `Exporter.applicationPropertyLine` uses it, and the Spring Boot and Quarkus overrides call it. - The application.properties of the exported project is written in ISO-8859-1, the encoding it is read in (by `camel run`, Camel Main's properties component without an `encoding`, and Spring Boot). The text of the file is written back as it was: UTF-8 text in the source is the same bytes in the export, so every runtime reads the exported file as it read the original, also Quarkus, which reads it in UTF-8. A character beyond ISO-8859-1 (from a `\uXXXX` escape) is written as a `\uXXXX` escape. - The run settings are written in UTF-8 (`RunSettings`), so the export reads them in UTF-8 (`RuntimeUtil.loadProperties(Properties, Path, Charset)`). - The `application-dev.properties` that `--console` appends to is read and written in ISO-8859-1 too, which keeps its bytes as they are. Before, a copied file with ISO-8859-1 text failed to be read as UTF-8. Left as it is: an escape such as `\u00e6` in the source becomes the ISO-8859-1 character in the export, which Quarkus (UTF-8) reads differently. Keeping both forms would need the raw lines of the source, which the export does not keep. ## Tests - `ExportHelperTest.testPropertyLineIsReadBackAsWritten`: backslashes, regex, keys with space, `=`, `:`, `#`, `!`, a leading space, control characters, ISO-8859-1 and a euro sign are read back by `Properties.load` as written; a URL keeps its colons. - `ProjectExporterTest.keepsTheEscapesAndTheEncodingOfTheApplicationProperties`: the cases of the table, in a UTF-8 application.properties: the exported project reads the same values as the source, and the UTF-8 line is the same. It fails without the fix (`path`). - camel-jbang-run (272 tests), camel-jbang-core including `RunExportGoldenTest` (golden files unchanged), and camel-jbang-plugin-kubernetes (156 tests) pass locally. - With the unpacked launcher and the new camel-jbang-run jar, `camel export` of the four lines of the table writes them as they are in the source, and the `greeting` line is byte-identical; the current launcher writes the second column of the table. _Claude Code on behalf of Claus Ibsen (davsclaus)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012nJsFsjqqFiwroeHRWaKbS -- 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]
