]> source.dussan.org Git - jgit.git/commit
FileUtils.rename(): better retry handling 22/204922/1
authorThomas Wolf <twolf@apache.org>
Sun, 8 Oct 2023 20:03:22 +0000 (22:03 +0200)
committerThomas Wolf <twolf@apache.org>
Sat, 14 Oct 2023 21:33:11 +0000 (23:33 +0200)
commitf6774fa8ee09f51ace5257b6cc43b7886b3f285a
tree3f840951849f923238e11ad48b1d157b0e9a2ead
parentcb46ee3544536525446317a98b5cb02377f0cfa5
FileUtils.rename(): better retry handling

When the atomic move fails on Windows, it may be because some other
thread is currently reading the destination. If we delete the file
then, that reader may get an exception, and conclude the file didn't
exist, even though the rename() would re-create it right away.

Try to avoid this from happening frequently by only deleting the
destination on the last retry. Also don't sleep after the last attempt.

Bug: 451508
Change-Id: I95bb4ec59d6e7efb4a7fc8d67f5df301f690257a
Signed-off-by: Thomas Wolf <twolf@apache.org>
org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java