Repository navigation
[#356] RotatableWriterTest: list the archives after the rotator stops, keep only the last listing - #361
Merged
vharseko merged 1 commit intoOct 18, 2026
Conversation
…er the rotator stops, keep only the last listing testAutomaticallyEvaluatesPolicesPeriodicallyIfRotationIntervalSpecified listed the archives while the rotator kept rotating the file every second. A listing taken during a rotation holds the renamed file, its .gz archive and the previous archive, which retention deletes only after the rotation. - The test closes the writer before it lists the archives: close() stops the rotator and waits for a rotation in progress, so the listing sees the state that retention left. - getAllHistoricalFiles() keeps only the last listing instead of adding each one to the previous ones, so a listing taken during a rotation no longer stays in the result; the unused existingFiles parameter is gone. Fixes OpenIdentityPlatform#356
maximthomas
approved these changes
Oct 18, 2026
maximthomas
left a comment
Contributor
There was a problem hiding this comment.
praise: The fix goes where the race is: the test now lists the archives only after the rotator has stopped.
rotatableWriter.close()runs beforeassertRetainedHistoricalFiles(RotatableWriterTest.java:439-444).RotatableWriter.close()callsawaitTerminationon the single scheduled task that rotates the file, compresses it (GzipUtil.compressRotatedFile) and applies retention, so the listing sees a directory nothing else is changing. I injected a 1500 ms sleep intocompressRotatedFileand the test passed at this head (1/1, 4.4 s).- The reproduction table in the description shows what each half of the change does: the helper change alone still fails at 1500 ms, and the helper change plus
close()passes.
This was referenced Oct 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RotatableWriterTest.testAutomaticallyEvaluatesPolicesPeriodicallyIfRotationIntervalSpecifiedlisted the archives while the rotator kept rotating the file every second, andgetAllHistoricalFiles()added each listing to the previous ones. A listing taken during a rotation holds the renamed file, its.gzarchive and the previous archive, which the retention check deletes only after the rotation, so the result never shrank back to one file.close()shuts the rotator down and waits for a running rotation and retention check, so the listing sees the state that retention left.getAllHistoricalFiles()keeps only the last listing instead of accumulating them; the unusedexistingFilesparameter is gone.Only the test changes.
Reproduction
A temporary
Thread.sleepinGzipUtil.compressRotatedFile(), before the uncompressed file is deleted, widened the rotation window, and the test ran 6 times (invocationCount = 6). Neither of these is part of the PR.mastermasterExpected size: 1 but was: 3(the renamed file, its.gz, the previous.gz) in ~4.3 s, as on CIclose()close()Testing
mvn -o -pl commons/audit/core -am test: 160 tests, 0 failures.RotatableWriterTestagain after the final comment edits: 18 tests, 0 failures.Fixes #356