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 2020/02/07 04:13:33 UTC
[camel] branch camel-3.0.x updated: [CAMEL-11947] Race condition in
iec60870 producer (#3547)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-3.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.0.x by this push:
new eec2793 [CAMEL-11947] Race condition in iec60870 producer (#3547)
eec2793 is described below
commit eec2793f08009c3ed45cdfa5e2c1eec22cd4b538
Author: Thomas Diesler <td...@redhat.com>
AuthorDate: Fri Feb 7 05:13:19 2020 +0100
[CAMEL-11947] Race condition in iec60870 producer (#3547)
---
.../iec60870/client/ClientConnection.java | 23 ++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/components/camel-iec60870/src/main/java/org/apache/camel/component/iec60870/client/ClientConnection.java b/components/camel-iec60870/src/main/java/org/apache/camel/component/iec60870/client/ClientConnection.java
index ffee89c..a50a679 100644
--- a/components/camel-iec60870/src/main/java/org/apache/camel/component/iec60870/client/ClientConnection.java
+++ b/components/camel-iec60870/src/main/java/org/apache/camel/component/iec60870/client/ClientConnection.java
@@ -19,6 +19,8 @@ package org.apache.camel.component.iec60870.client;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
import io.netty.channel.ChannelHandlerContext;
import org.apache.camel.component.iec60870.DiscardAckModule;
@@ -43,13 +45,6 @@ public class ClientConnection {
void update(ObjectAddress address, Value<?> value);
}
- private final StateListener stateListener = new StateListener() {
-
- @Override
- public void stateChanged(final State state, final Throwable e) {
- }
- };
-
private final DataHandler dataHandler = new AbstractDataProcessor() {
/**
@@ -99,7 +94,19 @@ public class ClientConnection {
public void start() {
final DataModule dataModule = new DataModule(this.dataHandler, this.options.getDataModuleOptions());
final ModulesFactory factory = () -> Arrays.asList(dataModule, new DiscardAckModule());
- this.client = new AutoConnectClient(this.host, this.port, this.options.getProtocolOptions(), factory, this.stateListener);
+ final CountDownLatch latch = new CountDownLatch(1);
+ this.client = new AutoConnectClient(this.host, this.port, this.options.getProtocolOptions(), factory, new StateListener() {
+ @Override
+ public void stateChanged(final State state, final Throwable e) {
+ if (state == State.CONNECTED)
+ latch.countDown();
+ }
+ });
+ try {
+ latch.await(2000, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException ex) {
+ // ignore
+ }
}
public void stop() throws Exception {