Making CodecRegistry thread-safe - #688
Open
Myllyenko wants to merge 1 commit into
Open
Conversation
Myllyenko
force-pushed
the
fix/codec-registry-thread-safety
branch
from
August 5, 2026 21:19
c90ea64 to
216423b
Compare
One CodecRegistry instance is shared by every reader and writer created from a TopicClient. getCodec is called from the compression threads (WriterQueue), from the decompression threads (MessageDecoder via Encoder.decode) and from gRPC callbacks, while registerCodec is public API that may be called at any time. Backing that with a plain HashMap means concurrent puts can lose entries or corrupt the table. Use a ConcurrentHashMap. The new test loses codecs on every run with the old implementation.
Myllyenko
force-pushed
the
fix/codec-registry-thread-safety
branch
from
August 5, 2026 21:36
216423b to
87390cb
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #688 +/- ##
============================================
+ Coverage 71.91% 71.94% +0.03%
- Complexity 3474 3478 +4
============================================
Files 390 390
Lines 16220 16220
Branches 1698 1698
============================================
+ Hits 11664 11669 +5
+ Misses 3904 3903 -1
+ Partials 652 648 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
One
CodecRegistryinstance is shared by every reader and writer created from aTopicClient.getCodecis called from the compression threads (WriterQueue), from the decompression threads (MessageDecoderviaEncoder.decode) and from gRPC callbacks, whileregisterCodecis public API that may be called at any time. Backing that with a plainHashMap(current implementation) means concurrent puts can lose entries or corrupt the table.