Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for issue 14256 #14262

Open
wants to merge 1 commit into
base: 3.2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class FileCacheStore {
private final File cacheFile;
private final File lockFile;
private final FileLock directoryLock;
private static final int MAX_RETRIES = 3;

private FileCacheStore(String cacheFilePath, File cacheFile, File lockFile, FileLock directoryLock) {
this.cacheFilePath = cacheFilePath;
Expand Down Expand Up @@ -150,10 +151,21 @@ private static void deleteFile(File f) {

Path pathOfFile = f.toPath();

try {
Files.delete(pathOfFile);
} catch (IOException ioException) {
logger.debug("Failed to delete file " + f.getAbsolutePath(), ioException);
for (int i = 0; i < MAX_RETRIES; i++) {
try {
Files.delete(pathOfFile);
if (!Files.exists(pathOfFile)) {
logger.debug("Successfully deleted file " + f.getAbsolutePath());
return;
}
} catch (IOException ioException) {
logger.debug("Failed to delete file " + f.getAbsolutePath() + " on attempt " + (i + 1), ioException);
}
try {
Thread.sleep(1000); // Pause before retrying
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any problem with not sleeping?

} catch (InterruptedException e) {
logger.warn("Thread interrupted while waiting to retry file deletion", e);
}
}
}

Expand Down
Loading