Hardening suggestions for Stirling-PDF / codex/investigate-cpu-usage-spikes-from-temp-file-manager (#4000)

I've reviewed the recently opened PR ([3992 - Improve temp cleanup
performance](https://github.com/Stirling-Tools/Stirling-PDF/pull/3992))
and have identified some area(s) that could benefit from additional
hardening measures.

These changes should help prevent potential security vulnerabilities and
improve overall code quality.

Thank you for your consideration!
🧚🤖  Powered by Pixeebot  

[Feedback](https://ask.pixee.ai/feedback) |
[Community](https://pixee-community.slack.com/signup#/domain-signup) |
[Docs](https://docs.pixee.ai/)
![](https://d1zaessa2hpsmj.cloudfront.net/pixel/v1/track?writeKey=2PI43jNm7atYvAuK7rJUz3Kcd6A&event=PR_HARDENING%7CStirling-Tools%2FStirling-PDF%7C73a340cbe2a46f976c4fd53dd9e54564d8d4de92)

Co-authored-by: pixeebot[bot] <104101892+pixeebot[bot]@users.noreply.github.com>
This commit is contained in:
pixeebot[bot] 2025-07-22 10:12:16 +01:00 committed by GitHub
parent 73a340cbe2
commit 1ad96242f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -182,7 +182,7 @@ public class TempFileCleanupServiceTest {
return FileTime.fromMillis(System.currentTimeMillis() - 5000000);
}
// For empty.tmp file, return a timestamp older than 5 minutes (for empty file test)
else if (fileName.equals("empty.tmp")) {
else if ("empty.tmp".equals(fileName)) {
return FileTime.fromMillis(System.currentTimeMillis() - 6 * 60 * 1000);
}
// For all other files, return a recent timestamp
@ -198,7 +198,7 @@ public class TempFileCleanupServiceTest {
String fileName = path.getFileName().toString();
// Return 0 bytes for the empty file
if (fileName.equals("empty.tmp")) {
if ("empty.tmp".equals(fileName)) {
return 0L;
}
// Return normal size for all other files
@ -327,7 +327,7 @@ public class TempFileCleanupServiceTest {
Path path = invocation.getArgument(0);
String fileName = path.getFileName().toString();
if (fileName.equals("empty.tmp")) {
if ("empty.tmp".equals(fileName)) {
// More than 5 minutes old
return FileTime.fromMillis(System.currentTimeMillis() - 6 * 60 * 1000);
} else {