Skip to content

[disk-buffering] Add guard for non-numeric files#2877

Merged
jaydeluca merged 3 commits into
open-telemetry:mainfrom
jaydeluca:disk-buffering-long-parse
May 28, 2026
Merged

[disk-buffering] Add guard for non-numeric files#2877
jaydeluca merged 3 commits into
open-telemetry:mainfrom
jaydeluca:disk-buffering-long-parse

Conversation

@jaydeluca

Copy link
Copy Markdown
Member

Description:

purgeExpiredFilesIfAny was calling Long.parseLong(... with no guard, which could throw NumberFormatException for non-numeric files. The fileToCacheFile method already had a pattern check so made this method consistnt with that approach.

Also a small update for the clear() method, just adding a more descriptive error message instead of a generic NPE if a directory is unreachable.

Copilot AI review requested due to automatic review settings May 27, 2026 20:15
@jaydeluca
jaydeluca requested a review from a team as a code owner May 27, 2026 20:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the disk-buffering folder handling by preventing NumberFormatException when encountering non-numeric files in the cache directory, and improves error reporting when clear() can’t list directory contents.

Changes:

  • Guard purgeExpiredFilesIfAny against non-numeric filenames to avoid Long.parseLong(...) failures.
  • Improve clear() failure mode by throwing an IOException when folder.listFiles() returns null.
  • Add regression tests covering non-numeric files and the new clear() error path.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/FolderManager.java Adds filename guard during purge and improves clear() error handling when directory listing fails.
disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/FolderManagerTest.java Adds tests ensuring non-numeric files don’t crash writes and that clear() throws a helpful IOException when the folder can’t be listed.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@jaydeluca jaydeluca changed the title disk-buffering: Add guard for non-numeric files [disk-buffering] Add guard for non-numeric files May 27, 2026

@LikeTheSalad LikeTheSalad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you 🙏

@jaydeluca
jaydeluca added this pull request to the merge queue May 28, 2026
Merged via the queue into open-telemetry:main with commit 3cd7103 May 28, 2026
22 checks passed
@jaydeluca
jaydeluca deleted the disk-buffering-long-parse branch May 28, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants