You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2021/11/05 05:59:04 UTC
[camel] branch main updated: LazyStartProducer: Fix potential race
condition in double-checked locking object initialization (#6382)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 3c7e49d LazyStartProducer: Fix potential race condition in double-checked locking object initialization (#6382)
3c7e49d is described below
commit 3c7e49d277c6bb0fe5fea2ade2e03a11709ff671
Author: Pascal Schumacher <pa...@gmx.net>
AuthorDate: Fri Nov 5 06:58:39 2021 +0100
LazyStartProducer: Fix potential race condition in double-checked locking object initialization (#6382)
---
.../main/java/org/apache/camel/support/LazyStartProducer.java | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/LazyStartProducer.java b/core/camel-support/src/main/java/org/apache/camel/support/LazyStartProducer.java
index 0fea3c3..3faee59 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/LazyStartProducer.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/LazyStartProducer.java
@@ -42,10 +42,11 @@ public final class LazyStartProducer extends DefaultAsyncProducer implements Del
if (delegate == null) {
synchronized (lock) {
if (delegate == null) {
- delegate = AsyncProcessorConverterHelper.convert(getEndpoint().createProducer());
- }
- if (!ServiceHelper.isStarted(delegate)) {
- ServiceHelper.startService(delegate);
+ AsyncProducer newDelegate = AsyncProcessorConverterHelper.convert(getEndpoint().createProducer());
+ if (!ServiceHelper.isStarted(newDelegate)) {
+ ServiceHelper.startService(newDelegate);
+ }
+ delegate = newDelegate;
}
}
}