jbonofre opened a new pull request, #3079:
URL: https://github.com/apache/karaf/pull/3079

   Follow-up to #3001, covering the non-blocking points from its review.
   
   ## Changes
   
   - **Fallback when an atomic move is not supported.** `FileUtils.atomicSave` 
now falls back to a plain `REPLACE_EXISTING` move on 
`AtomicMoveNotSupportedException`, as `SimpleDownloadTask` and 
`FeatureConfigInstaller.updateStorage` already do. Before, every save of 
`state.json` and `digraph.json` failed on such a file system, where the old 
in-place write worked.
   - **The resolve request is saved atomically.** 
`FeaturesServiceImpl.writeResolve` still wrote the `resolve` file in place, and 
`checkResolve` reads it back at startup, so it had the same truncation risk as 
the state. It now goes through `FileUtils.atomicSave`.
   - **No truncating stream left in the Activator.** Since #3001 overrides 
`save()` in the Activator's `StateStorage`, `getOutputStream()` is no longer 
called. It now throws instead of opening a truncating `FileOutputStream` on 
`state.json`, so the non-atomic write can't come back by accident.
   - **Test fix.** The comment in 
`ActivatorStateStorageTest.testInterruptedSaveKeepsPreviousState` said the save 
fails after it started writing. `JsonWriter` buffers its output, so it actually 
fails before anything reaches the temporary file (`FileUtilsTest` covers a save 
that fails part way through). The comment is corrected, and the test now checks 
that no temporary file is left behind.
   
   ## Testing
   
   - [x] `mvn -pl util,features/core install` passes with JDK 17 (24 tests in 
`util`, 145 in `features/core`), including the new 
`FeaturesServiceImplTest.testPersistResolveRequest`.
   - The fallback path isn't covered by a unit test, as 
`AtomicMoveNotSupportedException` can't be triggered on a local file system.
   


-- 
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]

Reply via email to