Skip to content

Commit

Permalink
Check condition after calling lock method
Browse files Browse the repository at this point in the history
  • Loading branch information
ngocnhan-tran1996 committed Oct 20, 2024
1 parent add7744 commit 2408622
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ private Producer createOrGetProducer() {
if (this.producer == null) {
this.lock.lock();
try {
if (this.producer == null) {
ProducerBuilder builder = this.environment.producerBuilder();
if (this.superStreamRouting == null) {
builder.stream(this.streamName);
Expand All @@ -125,6 +126,7 @@ private Producer createOrGetProducer() {
((DefaultStreamMessageConverter) this.streamConverter).setBuilderSupplier(
() -> this.producer.messageBuilder());
}
}
}
finally {
this.lock.unlock();
Expand Down Expand Up @@ -332,8 +334,10 @@ public void close() {
if (this.producer != null) {
this.lock.lock();
try {
if (this.producer != null) {
this.producer.close();
this.producer = null;
}
}
finally {
this.lock.unlock();
Expand Down

0 comments on commit 2408622

Please sign in to comment.