davsclaus commented on code in PR #28319:
URL: https://github.com/apache/camel/pull/28319#discussion_r4357366482


##########
components/camel-tahu/src/main/java/org/apache/camel/component/tahu/TahuEdgeProducer.java:
##########
@@ -174,7 +257,12 @@ protected void doStop() throws Exception {
 
             Future<?> clientFuture = 
descriptorFutures.remove(edgeNodeDescriptor);
             if (clientFuture != null) {
-                tahuEdgeClient.shutdown();
+                TahuEdgeClient client = tahuEdgeClient;

Review Comment:
   This is the producer's own reference, which can be stale: if another Edge 
Node producer of the same Edge Node was restarted since this producer last 
called `currentClient()`, the future just removed belongs to the new client, 
while this shuts down (again) the old one. The new client then keeps running 
and stays in `descriptorClients` with nobody left to shut it down.
   
   ```suggestion
                   TahuEdgeClient client = currentClient();
   ```



##########
components/camel-tahu/src/main/java/org/apache/camel/component/tahu/TahuEdgeProducer.java:
##########
@@ -95,15 +137,7 @@ public void process(Exchange exchange) throws 
InvalidPayloadException {
 
     private TahuEdgeClient createClient(TahuEdgeEndpoint endpoint, 
EdgeNodeDescriptor edgeNodeDescriptor) {
 
-        // Only create clients for Edge Nodes, not Devices. If passed a
-        // DeviceDescriptor, create/lookup based on its EdgeNodeDescriptor, 
i.e. minus
-        // its deviceId.
-        EdgeNodeDescriptor clientCreationDescriptor = edgeNodeDescriptor;
-        if (edgeNodeDescriptor.isDeviceDescriptor()) {
-            clientCreationDescriptor = ((DeviceDescriptor) 
edgeNodeDescriptor).getEdgeNodeDescriptor();
-        }
-
-        TahuEdgeClient tahuEdgeClient = 
descriptorClients.computeIfAbsent(clientCreationDescriptor, end -> {
+        TahuEdgeClient tahuEdgeClient = 
descriptorClients.computeIfAbsent(clientDescriptor, end -> {

Review Comment:
   With the client removed on stop, a Device producer created while the Edge 
Node producer is stopped now reaches this `computeIfAbsent` with the Device 
endpoint: `endpoint.getDeviceIdList()` throws an NPE when the Device URI has no 
`deviceIds` (an edge-node-only option), so the Device route fails to start. 
Could Device producers only look the client up instead of creating it?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to