Skip to content

[Robustness] RotatingStreamWriter.cs — EnforceMaxRotations silently swallows File.Delete exceptions #476

@Christophe-Rogiers

Description

@Christophe-Rogiers

Severity: Warning

File: src/Servy.Core/IO/RotatingStreamWriter.cs, lines 363–366

Description:
When rotation limit deletion fails (e.g., antivirus lock, file in use), the exception is swallowed silently. The file is not deleted and no counter tracks skipped deletions. Over time, the rotated file count can grow unboundedly, potentially filling disk.

The Rotate() method has a circuit-breaker pattern for failures, but EnforceMaxRotations does not.

Suggested fix:
Log a warning when deletion fails (consistent with the logging approach in Rotate()), and consider tracking consecutive failures to alert operators.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions