SyncWriter.flush() now throw Exception when previous task was failed #484
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.
Problem connected to this one #475
What's the cause?
A problem when encoding/decoding (or something else) throws an error.
The user writes
Code in writer.send failed because codec CUSTOM did not exist.
But the problem is when it's failed before or writer.flush();
When we call writer.flush(), we finally end up in flushImpl.
Take a look at in WriterImpl
If the thread was too quick, then lastAcceptedMessageFuture - DONE(with error inside future), we return CompletableFuture.completedFuture(null) and writer.flush() doesn't fail.
If the thread is slow, then lastAcceptedMessageFuture is NOT COMPLETED, and we call lastAcceptedMessageFuture.thenApply(v -> null) and failed with RuntimeException wraped by CompletionException
Behavior depends on the speed of the test/machine and so on.
Solution
I think that we should throw an error in writer.flush()
Return his. lastAcceptedMessageFuture.thenApply(v -> null); despite whether lastAcceptedMessageFuture is done or not
Test
A bit confused where to write the test.
Test depends on #447 (Codec class)
Also, in MR below, we can uncomment Ignore test in YdbTopicsCodecIntegrationTest they will pass.
Maybe wait for MR to push?
On the other hand I can write simple one test -> just push Thread.sleep(5000) before writer.flush();