exceptionfactory commented on code in PR #10499:
URL: https://github.com/apache/nifi/pull/10499#discussion_r2494901594


##########
nifi-extension-bundles/nifi-aws-bundle/nifi-aws-kinesis/src/main/java/org/apache/nifi/processors/aws/kinesis/ConsumeKinesis.java:
##########
@@ -477,6 +487,19 @@ private static InitialPositionInStreamExtended 
getInitialPosition(final ProcessC
         };
     }
 
+    private String generateWorkerId() {
+        final String processorId = getIdentifier();
+        final NodeTypeProvider nodeTypeProvider = getNodeTypeProvider();
+
+        if (!nodeTypeProvider.isClustered()) {
+            return processorId;
+        }
+
+        // If a node id is not available for some reason, generating a random 
UUID helps to avoid collisions.
+        final String nodeId = 
nodeTypeProvider.getCurrentNode().orElse(UUID.randomUUID().toString());
+        return "%s@%s".formatted(processorId, nodeId);

Review Comment:
   Recommend adjusting the approach to use a single return:
   
   ```suggestion
           final String workerId;
   
           if (nodeTypeProvider.isClustered()) {
               // If a node id is not available for some reason, generating a 
random UUID helps to avoid collisions.
               final String nodeId = 
nodeTypeProvider.getCurrentNode().orElse(UUID.randomUUID().toString());
               workerId = "%s@%s".formatted(processorId, nodeId);
           } else {
               workerId = processorId;
           }
   
           return workerId;
   ```



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