diff --git a/spring-kafka-docs/src/main/antora/modules/ROOT/pages/testing.adoc b/spring-kafka-docs/src/main/antora/modules/ROOT/pages/testing.adoc index 5948e41d1e..9504bf1cfd 100644 --- a/spring-kafka-docs/src/main/antora/modules/ROOT/pages/testing.adoc +++ b/spring-kafka-docs/src/main/antora/modules/ROOT/pages/testing.adoc @@ -162,21 +162,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(); - } - } ----