-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix MonoPublishOnTest flakiness #3898
Conversation
The implementation relied on a specific sequencing of events, which in case of slower hardware or random events would occasionally fail the assertions. This change introduces firm ordering and fixes an incorrect assertion, which assumed the `Mono` terminates without error, while in fact the `RejectedExecutionException` is propagated to the `AssertSubscriber`. In effect, the tests are no longer flaky.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
except some formatting issues, it is ok
@@ -127,23 +130,26 @@ public void rejectedExecutionExceptionOnErrorSignalExecutor() | |||
.publishOn(fromExecutorService(executor)) | |||
.doOnNext(s -> { | |||
try { | |||
inOnNextLatch.countDown(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you may want to fix the formatting
latch.await(); | ||
} | ||
catch (InterruptedException e) { | ||
throw Exceptions.propagate(exception); | ||
} | ||
}) | ||
.publishOn(fromExecutor(executor)) | ||
.doFinally(s -> finallyLatch.countDown()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you may want to fix the formatting
@@ -182,22 +188,25 @@ public void rejectedExecutionExceptionOnDataSignalExecutorService() | |||
.publishOn(fromExecutorService(executor)) | |||
.doOnNext(s -> { | |||
try { | |||
inOnNextLatch.countDown(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you may want to fix the formatting
latch.await(); | ||
} | ||
catch (InterruptedException e) { | ||
} | ||
}) | ||
.publishOn(fromExecutorService(executor)) | ||
.doFinally(s -> finallyLatch.countDown()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you may want to fix the formatting
@@ -236,23 +245,26 @@ public void rejectedExecutionExceptionOnErrorSignalExecutorService() | |||
.publishOn(fromExecutorService(executor)) | |||
.doOnNext(s -> { | |||
try { | |||
inOnNextLatch.countDown(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you may want to fix the formatting
Thanks. I think I addressed all of them now. |
The implementation relied on a specific sequencing of events, which in case of slower hardware or random events would occasionally fail the assertions. This change introduces firm ordering and fixes an incorrect assertion, which assumed the
Mono
terminates without error, while in fact theRejectedExecutionException
is propagated to theAssertSubscriber
. In effect, the tests are no longer flaky.