Skip to content

Commit c1f45d2

Browse files
committed
refactor example code
Signed-off-by: moonyoungCHAE <xpf_fl@naver.com>
1 parent bc07101 commit c1f45d2

File tree

1 file changed

+10
-12
lines changed
  • spring-kafka-docs/src/main/antora/modules/ROOT/pages

1 file changed

+10
-12
lines changed

spring-kafka-docs/src/main/antora/modules/ROOT/pages/testing.adoc

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)