Skip to content

Commit

Permalink
ACS-6168: Add 5 retries when retrieving the temp directory to deal wi…
Browse files Browse the repository at this point in the history
…th clashes when high load is applied immediatelly at startup
  • Loading branch information
mstrankowski committed Oct 26, 2023
1 parent 19feada commit ab70588
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,16 @@ private static File getTempDir()

final File systemTempDir = new File(systemTempDirPath);
final File tempDir = new File(systemTempDir, dirName);
if (!tempDir.exists() && !tempDir.mkdirs() && !tempDir.exists())
{
throw new RuntimeException("Failed to create temp directory: " + tempDir);

int retrieveTempDirAttemptLimit = 5;
for (int i = 0; i < retrieveTempDirAttemptLimit; i++) {
if (tempDir.exists() || tempDir.mkdirs())
{
return tempDir;
}
}

return tempDir;
throw new RuntimeException("Failed to create temp directory: " + tempDir);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,16 @@ private static File getTempDir()

final File systemTempDir = new File(systemTempDirPath);
final File tempDir = new File(systemTempDir, dirName);
if (!tempDir.exists() && !tempDir.mkdirs())
{
throw new RuntimeException("Failed to create temp directory: " + tempDir);

int retrieveTempDirAttemptLimit = 5;
for (int i = 0; i < retrieveTempDirAttemptLimit; i++) {
if (tempDir.exists() || tempDir.mkdirs())
{
return tempDir;
}
}

return tempDir;
throw new RuntimeException("Failed to create temp directory: " + tempDir);
}
}
}

0 comments on commit ab70588

Please sign in to comment.