nandorsoma commented on code in PR #6225:
URL: https://github.com/apache/nifi/pull/6225#discussion_r957813444


##########
nifi-nar-bundles/nifi-mqtt-bundle/nifi-mqtt-processors/src/main/java/org/apache/nifi/processors/mqtt/PublishMQTT.java:
##########
@@ -201,35 +191,35 @@ private void initializeClient(ProcessContext context) {
         // non-null but not connected, so we need to handle each case and only 
create a new client when it is null
         try {
             if (mqttClient == null) {
-                logger.debug("Creating client");
-                mqttClient = createMqttClient(broker, clientID, persistence);
+                mqttClient = createMqttClient();
                 mqttClient.setCallback(this);
             }
 
             if (!mqttClient.isConnected()) {
-                logger.debug("Connecting client");
-                mqttClient.connect(connOpts);
+                mqttClient.connect();
             }
-        } catch (MqttException e) {
-            logger.error("Connection to {} lost (or was never connected) and 
connection failed. Yielding processor", new Object[]{broker}, e);
+        } catch (Exception e) {
+            logger.error("Connection to {} lost (or was never connected) and 
connection failed. Yielding processor", clientProperties.getBroker(), e);
             context.yield();
         }
     }
 
     @Override
     public void connectionLost(Throwable cause) {
-        logger.error("Connection to {} lost due to: {}", new Object[]{broker, 
cause.getMessage()}, cause);
+        logger.error("Connection to {} lost due to: {}", new 
Object[]{clientProperties.getBroker(), cause.getMessage()}, cause);

Review Comment:
   Are you sure? If I remove the object wrapper `void error(String msg, 
Object... os);` will be used instead of `void error(String msg, Object[] os, 
Throwable t);`. I didn't test what happens in this situation with NiFi logging, 
but if I remember right Slf4j throws an error when there are less placeholder 
than passed parameters. I expect the same in our case. Also we would loose the 
cause stack trace.



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