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


##########
components/camel-azure/camel-azure-iothub/src/main/java/org/apache/camel/component/azure/iothub/client/DeviceClientPool.java:
##########
@@ -403,27 +416,28 @@ private static String resolvePoolKey(String deviceId, 
String connectionString) {
                 }
             }
         }
-        if (csDeviceId != null && !csDeviceId.equals(deviceId)) {
+        boolean hasDeviceId = deviceId != null && !deviceId.isBlank();
+        if (hasDeviceId && csDeviceId != null && !csDeviceId.equals(deviceId)) 
{
             throw new IllegalArgumentException(
                     "Device id '" + deviceId + "' does not match the 
connection string's DeviceId '" + csDeviceId + "'");
         }
-        StringBuilder identity = new StringBuilder();
-        if (hostName != null && !hostName.isBlank()) {
-            identity.append(hostName);
-        }
-        if (csDeviceId != null && !csDeviceId.isBlank()) {
-            if (!identity.isEmpty()) {
-                identity.append(':');
-            }
-            identity.append(csDeviceId);
-        }
-        if (moduleId != null && !moduleId.isBlank()) {
-            if (!identity.isEmpty()) {
-                identity.append(':');
-            }
-            identity.append(moduleId);
+        String device = csDeviceId != null && !csDeviceId.isBlank() ? 
csDeviceId : hasDeviceId ? deviceId : null;

Review Comment:
   💡 **Nit (readability):** The nested ternary without parentheses is correct 
(right-associative) but can be harder to parse at a glance. Consider grouping 
the inner condition explicitly:
   
   ```suggestion
           String device = csDeviceId != null && !csDeviceId.isBlank() ? 
csDeviceId : (hasDeviceId ? deviceId : null);
   ```



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