File tree Expand file tree Collapse file tree 1 file changed +10
-12
lines changed
spring-kafka-docs/src/main/antora/modules/ROOT/pages Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -158,21 +158,19 @@ public final class EmbeddedKafkaHolder {
158158 private static EmbeddedKafkaBroker embeddedKafka = new EmbeddedKafkaZKBroker(1, false)
159159 .brokerListProperty("spring.kafka.bootstrap-servers");
160160
161- private static boolean started;
161+ private static volatile boolean started;
162162
163163 public static EmbeddedKafkaBroker getEmbeddedKafka() {
164164 if (!started) {
165- synchronized (this) {
166- if (!started) {
167- try {
168- embeddedKafka.afterPropertiesSet();
169- }
170- catch (Exception e) {
171- throw new KafkaException("Embedded broker failed to start", e);
172- }
173- started = true;
174- }
175- }
165+ synchronized (EmbeddedKafkaBroker.class) {
166+ try {
167+ embeddedKafka.afterPropertiesSet();
168+ }
169+ catch (Exception e) {
170+ throw new KafkaException("Embedded broker failed to start", e);
171+ }
172+ started = true;
173+ }
176174 }
177175 return embeddedKafka;
178176 }
You can’t perform that action at this time.
0 commit comments