Race condition in OutputCapture can result in stale data#46685
Closed
schmidti159 wants to merge 1 commit intospring-projects:mainfrom
Closed
Race condition in OutputCapture can result in stale data#46685schmidti159 wants to merge 1 commit intospring-projects:mainfrom
schmidti159 wants to merge 1 commit intospring-projects:mainfrom
Conversation
This race could occur because of the existing cache in OutputCapture: When data was written, while it was read, any following reading of data might miss the last output. The cache was not invalidated correctly in this case. We are now versioning the cache entries to make sure this can't happen anymore. Signed-off-by: Daniel Schmidt <[email protected]>
d87a89d to
5c9fc74
Compare
philwebb
pushed a commit
that referenced
this pull request
Aug 8, 2025
Update `OutputCapture` to fix a race condition that could occur due to the cache. Prior to this commit, when data was written whilst simultaneously being read, any subsequent reading of data might miss the last output. See gh-46685 Signed-off-by: Daniel Schmidt <[email protected]>
philwebb
added a commit
that referenced
this pull request
Aug 8, 2025
Member
|
Thanks very much @schmidti159. I've tried to simplify things a bit by using a different type of object to represent no cached data. This removes the need to have the atomic counters. The test still passes, but please let me know if you spot any potential issues. |
izeye
added a commit
to izeye/micrometer
that referenced
this pull request
Aug 9, 2025
See spring-projects/spring-boot#46685 Signed-off-by: Johnny Lim <[email protected]>
jonatan-ivanov
pushed a commit
to micrometer-metrics/micrometer
that referenced
this pull request
Aug 11, 2025
See spring-projects/spring-boot#46685 Signed-off-by: Johnny Lim <[email protected]>
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.
There is a race condition in
OutputCaptureused in theOutputCaptureExtensionthat could lead to flaky test results.This race could occur because of the existing cache in
OutputCapture: When data was written, while it was read, any following reading of data might miss the last output. The cache was not invalidated correctly in this case.We are now versioning the cache entries to make sure this can't happen anymore. When invalidating the cache we also increase the version.