jbonofre opened a new pull request, #2900: URL: https://github.com/apache/karaf/pull/2900
Backport of #2897 to `karaf-4.4.x`. ## Summary Fixes #2805. `FeatureConfigInstaller.updateExistingConfig()` (used both for the `append` and `override` config flows) read the existing cfg file, merged in the new properties in memory, then wrote the result directly back to the target file. Calling `cfg.update(...)` just before that write also triggers Configuration Admin to notify its persistence manager (fileinstall), which persists the same configuration to the same cfg file on the CM Event Dispatcher thread. With two unsynchronized, non-atomic writers hitting the same file at once, the writes can interleave and corrupt the file. The "file doesn't exist yet" path already avoided this by writing to a temp file and renaming it atomically into place (KARAF-7389 / #1489), but that fix didn't cover the "file already exists" path exercised by `append`/`override`. This applies the same temp-file + atomic rename pattern to `updateExistingConfig()`, for both the properties and JSON formats. Includes two follow-up fixes from the original PR: - Use `Files.move` with `REPLACE_EXISTING` instead of `File.renameTo()` (avoids silent failure on Windows when the destination already exists) - Add a fallback for the atomic file move ## Test plan - [x] Cherry-picked cleanly from main (3 commits) - [x] `mvn -pl features/core test -Dtest=FeatureConfigInstallerTest` passes on `karaf-4.4.x` -- 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]
