Altered the example in EmbeddedKafkaHolder usage (#3929)
Integration tests with an EmbeddedKafka instance are sometimes run in parallel in Junit.
The current example is not thread safe, so I think the oficial documentation should account for that.
Signed-off-by: mipo256 <mikhailpolivakha@gmail.com>
(cherry picked from commit 579e7cb8ff)
This commit is contained in:
committed by
Spring Builds
parent
83abedf423
commit
110a3ce1cb
@@ -180,21 +180,20 @@ public final class EmbeddedKafkaHolder {
|
||||
|
||||
public static EmbeddedKafkaBroker getEmbeddedKafka() {
|
||||
if (!started) {
|
||||
try {
|
||||
embeddedKafka.afterPropertiesSet();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new KafkaException("Embedded broker failed to start", e);
|
||||
}
|
||||
started = true;
|
||||
synchronized (this) {
|
||||
if (!started) {
|
||||
try {
|
||||
embeddedKafka.afterPropertiesSet();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new KafkaException("Embedded broker failed to start", e);
|
||||
}
|
||||
started = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return embeddedKafka;
|
||||
}
|
||||
|
||||
private EmbeddedKafkaHolder() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
Reference in New Issue
Block a user