Copilot commented on code in PR #3411:
URL: https://github.com/apache/tika/pull/3411#discussion_r4366958348


##########
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:
   The fixed `.tmp` pathname is shared across store instances and processes, 
but `synchronized` only protects one instance. If another writer deletes, 
recreates, and renames that file before the first writer reaches 
`writeValue(File, ...)`, serialization recreates the missing path with 
umask-derived permissions and can publish a 0644 credential store under umask 
022. Create a unique sibling temporary file with owner-only attributes for each 
save so concurrent writers cannot remove each other's temporary files.



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