Skip to content

Commit 2408622

Browse files
Check condition after calling lock method
1 parent add7744 commit 2408622

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

spring-rabbit-stream/src/main/java/org/springframework/rabbit/stream/producer/RabbitStreamTemplate.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ private Producer createOrGetProducer() {
111111
if (this.producer == null) {
112112
this.lock.lock();
113113
try {
114+
if (this.producer == null) {
114115
ProducerBuilder builder = this.environment.producerBuilder();
115116
if (this.superStreamRouting == null) {
116117
builder.stream(this.streamName);
@@ -125,6 +126,7 @@ private Producer createOrGetProducer() {
125126
((DefaultStreamMessageConverter) this.streamConverter).setBuilderSupplier(
126127
() -> this.producer.messageBuilder());
127128
}
129+
}
128130
}
129131
finally {
130132
this.lock.unlock();
@@ -332,8 +334,10 @@ public void close() {
332334
if (this.producer != null) {
333335
this.lock.lock();
334336
try {
337+
if (this.producer != null) {
335338
this.producer.close();
336339
this.producer = null;
340+
}
337341
}
338342
finally {
339343
this.lock.unlock();

0 commit comments

Comments
 (0)