gnodet-bot commented on code in PR #26476:
URL: https://github.com/apache/camel/pull/26476#discussion_r4018136805


##########
components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoConsumer.java:
##########
@@ -74,15 +78,26 @@ protected void doStart() throws Exception {
                 client.connect(connectOptions);
             }
 

Review Comment:
   ⚠️ **Naming collision with existing catch-block variable:** `boolean 
ownedClient` at line 79 uses the same name as `MqttClient ownedClient` declared 
in the catch block below (line ~128 of the new file). They live in separate 
scopes so there is no compile error, but the name clash is confusing — a reader 
scanning for `ownedClient` will find two identically-named locals with 
completely different types in close proximity.
   
   The MQTT5 counterpart (`PahoMqtt5Consumer`) avoids this by reading the 
`stopClient` volatile field directly inside the anonymous class, which is 
equally safe and avoids the alias:
   
   ```suggestion
               boolean isOwnedClient = stopClient;
               callbackClient.setCallback(new MqttCallbackExtended() {
   ```
   
   Then update the reference inside `connectComplete` from `ownedClient` to 
`isOwnedClient`.



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