mrdevel2002-ui commented on code in PR #3411:
URL: https://github.com/apache/tika/pull/3411#discussion_r4371728656
##########
tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/config/FileBasedConfigStore.java:
##########
@@ -152,7 +159,9 @@ private synchronized void loadFromFile() throws IOException
{
private synchronized void saveToFile() {
try {
// Write to temp file first, then atomic rename
- Path tempFile = Paths.get(configFile.toString() + ".tmp");
+ Path tempFile = configFile.resolveSibling(configFile.getFileName()
+ ".tmp");
+ Files.deleteIfExists(tempFile);
+ Files.createFile(tempFile, ownerOnly());
Review Comment:
Fair point, `synchronized` only covers one instance, and a shared
`config-store.json.tmp` lets a second writer pull the file out from under the
first. Fixed in 62b05d1: each save now goes through `Files.createTempFile` in
the store's directory with the owner-only attribute, so every writer gets its
own name and nobody else deletes or recreates it. The temp file is also removed
if the write or move fails. The test now checks that the directory holds
nothing but `config-store.json` after the saves.
--
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]