Class AtomicFileWriter
java.lang.Object
io.jenkins.plugins.configsplice.engine.AtomicFileWriter
Replaces one file's contents through a same-directory temporary file (SRS section 13.2).
The guarantee callers depend on is not "the write succeeded" but "the target is either fully old or fully new, never truncated". Writing in place cannot offer that; a crash or a failed write halfway through leaves a config file that parses as neither.
The temporary file is a sibling of the target, never in the system temp directory. Two reasons, and the second is the important one: a rename is only atomic within a filesystem, and the temp file transiently holds the same content as the target — including any resolved credential — so it must inherit the workspace's access controls rather than a world-traversable temp directory's.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordWhat actually happened, for logging and for the gate 4 evidence record. -
Method Summary
Modifier and TypeMethodDescriptionstatic AtomicFileWriter.OutcomeAtomically replacestarget's contents withcontent.
-
Method Details
-
replace
Atomically replacestarget's contents withcontent.On any failure the target keeps its original bytes and the temporary file is removed.
- Throws:
SpliceException-ErrorCode.WRITE_FAILEDon any I/O failure
-