Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
2.6.0
-
None
-
None
Description
In testing my project, I discovered that the MockProducer is not thread safe as I thought. It doesn't use thread safe libraries for it's underlying stores, and only some of it’s methods are synchronised.
As performance isn’t an issue for this, I would propose simply synchronising all public methods in the class, as some already are.
In my project, send is synchronised and commit transactions isn’t. This was causing weird collection manipulation and messages going missing. My lolcat only solution was simply to synchronise on the MockProducer instance before calling commit.
See my workaround: https://github.com/astubbs/async-consumer/pull/13/files#diff-8e93aa2a2003be7436f94956cf809b2eR558
PR available: https://github.com/apache/kafka/pull/9154