pvillard31 commented on code in PR #11804:
URL: https://github.com/apache/nifi/pull/11804#discussion_r4269367251


##########
nifi-extension-bundles/nifi-mqtt-bundle/nifi-mqtt-processors/src/main/java/org/apache/nifi/processors/mqtt/adapters/HiveMqV5ClientAdapter.java:
##########
@@ -157,7 +148,17 @@ public void 
setReceivedMessageHandler(ReceivedMqttMessageHandler handler) {
         });
     }
 
-    private static Mqtt5BlockingClient createClient(URI brokerUri, 
MqttClientProperties clientProperties, ComponentLog logger) throws TlsException 
{
+    private <T> T awaitWithTimeout(Future<T> future) {
+        try {
+            final T response = 
future.get(clientProperties.getConnectionTimeout(), TimeUnit.SECONDS);

Review Comment:
   When get() times out, the HiveMQ operation keeps running and ConsumeMQTT 
drops the client without a disconnect. Should we disconnect here, or set the 
HiveMQ transport connect timeouts instead, so a late connect cannot leave a 
client nobody can clean up?



##########
nifi-extension-bundles/nifi-mqtt-bundle/nifi-mqtt-processors/src/main/java/org/apache/nifi/processors/mqtt/adapters/HiveMqV5ClientAdapter.java:
##########
@@ -157,7 +148,17 @@ public void 
setReceivedMessageHandler(ReceivedMqttMessageHandler handler) {
         });
     }
 
-    private static Mqtt5BlockingClient createClient(URI brokerUri, 
MqttClientProperties clientProperties, ComponentLog logger) throws TlsException 
{
+    private <T> T awaitWithTimeout(Future<T> future) {
+        try {
+            final T response = 
future.get(clientProperties.getConnectionTimeout(), TimeUnit.SECONDS);
+            logger.debug("Received response: {}", response);
+            return response;

Review Comment:
   Should we catch InterruptedException separately and restore the interrupt 
status with Thread.currentThread().interrupt()?



-- 
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