Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flush appenders before stopping #6314

Merged
merged 1 commit into from
Dec 8, 2022

Conversation

zUniQueX
Copy link
Member

@zUniQueX zUniQueX commented Dec 8, 2022

Attempt to fix an unstable test in the class TlsSocketAppenderFactoryTest.

Problem:

loggingFactory.reset() must be called in order to receive the logged messages because it closes the OutputStream of the Socket in the appender. The relevant call is detachAndStopAllAppenders() which eventually closes the appender but maybe discards messages to be written asynchronously.

If the appender is closed before all asynchronously messages are written, the test fails. This leads to a race condition between writing the log messages and closing the appender.

Solution:

loggingFactory.stop() will attempt to flush outstanding log messages, so the messages should all be written when the appender eventually gets stopped.

@gitpod-io
Copy link

gitpod-io bot commented Dec 8, 2022

@zUniQueX zUniQueX marked this pull request as ready for review December 8, 2022 15:00
@zUniQueX zUniQueX requested a review from a team as a code owner December 8, 2022 15:00
@zUniQueX zUniQueX merged commit cba8928 into dropwizard:release/2.1.x Dec 8, 2022
@zUniQueX zUniQueX deleted the fix-flaky-test branch December 8, 2022 15:01
@joschi joschi added this to the 2.1.5 milestone Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants