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


##########
nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ProcessGroupStatusSnapshotDTO.java:
##########
@@ -563,28 +563,66 @@ public ProcessGroupStatusSnapshotDTO clone() {
 
         other.setProcessingNanos(getProcessingNanos());
 
-        
other.setConnectionStatusSnapshots(copy(getConnectionStatusSnapshots()));
-        other.setProcessorStatusSnapshots(copy(getProcessorStatusSnapshots()));
-        
other.setRemoteProcessGroupStatusSnapshots(copy(getRemoteProcessGroupStatusSnapshots()));
-        other.setInputPortStatusSnapshots(copy(getInputPortStatusSnapshots()));
-        
other.setOutputPortStatusSnapshots(copy(getOutputPortStatusSnapshots()));
+        if (getConnectionStatusSnapshots() != null) {
+            final List<ConnectionStatusSnapshotEntity> 
collectionStatusSnapshotEntities = new ArrayList<>();
+            for (final ConnectionStatusSnapshotEntity 
connectionStatusSnapshotEntity :  getConnectionStatusSnapshots()) {

Review Comment:
   The spacing is off slightly:
   ```suggestion
               for (final ConnectionStatusSnapshotEntity 
connectionStatusSnapshotEntity : getConnectionStatusSnapshots()) {
   ```



##########
nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ProcessGroupStatusSnapshotDTO.java:
##########
@@ -563,28 +563,66 @@ public ProcessGroupStatusSnapshotDTO clone() {
 
         other.setProcessingNanos(getProcessingNanos());
 
-        
other.setConnectionStatusSnapshots(copy(getConnectionStatusSnapshots()));
-        other.setProcessorStatusSnapshots(copy(getProcessorStatusSnapshots()));
-        
other.setRemoteProcessGroupStatusSnapshots(copy(getRemoteProcessGroupStatusSnapshots()));
-        other.setInputPortStatusSnapshots(copy(getInputPortStatusSnapshots()));
-        
other.setOutputPortStatusSnapshots(copy(getOutputPortStatusSnapshots()));
+        if (getConnectionStatusSnapshots() != null) {
+            final List<ConnectionStatusSnapshotEntity> 
collectionStatusSnapshotEntities = new ArrayList<>();
+            for (final ConnectionStatusSnapshotEntity 
connectionStatusSnapshotEntity :  getConnectionStatusSnapshots()) {
+                ConnectionStatusSnapshotEntity clone = 
connectionStatusSnapshotEntity.clone();
+                clone.setId(connectionStatusSnapshotEntity.getId());
+                collectionStatusSnapshotEntities.add(clone);
+            }
+            
other.setConnectionStatusSnapshots(collectionStatusSnapshotEntities);
+        }
+
+        if (getProcessorStatusSnapshots() != null) {
+            final List<ProcessorStatusSnapshotEntity> 
processorStatusSnapshotEntities = new ArrayList<>();
+            for (final ProcessorStatusSnapshotEntity 
processorStatusSnapshotEntity :  getProcessorStatusSnapshots() ) {

Review Comment:
   ```suggestion
               for (final ProcessorStatusSnapshotEntity 
processorStatusSnapshotEntity : getProcessorStatusSnapshots() ) {
   ```



##########
nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ProcessGroupStatusSnapshotDTO.java:
##########
@@ -563,28 +563,66 @@ public ProcessGroupStatusSnapshotDTO clone() {
 
         other.setProcessingNanos(getProcessingNanos());
 
-        
other.setConnectionStatusSnapshots(copy(getConnectionStatusSnapshots()));
-        other.setProcessorStatusSnapshots(copy(getProcessorStatusSnapshots()));
-        
other.setRemoteProcessGroupStatusSnapshots(copy(getRemoteProcessGroupStatusSnapshots()));
-        other.setInputPortStatusSnapshots(copy(getInputPortStatusSnapshots()));
-        
other.setOutputPortStatusSnapshots(copy(getOutputPortStatusSnapshots()));
+        if (getConnectionStatusSnapshots() != null) {
+            final List<ConnectionStatusSnapshotEntity> 
collectionStatusSnapshotEntities = new ArrayList<>();
+            for (final ConnectionStatusSnapshotEntity 
connectionStatusSnapshotEntity :  getConnectionStatusSnapshots()) {
+                ConnectionStatusSnapshotEntity clone = 
connectionStatusSnapshotEntity.clone();
+                clone.setId(connectionStatusSnapshotEntity.getId());
+                collectionStatusSnapshotEntities.add(clone);
+            }
+            
other.setConnectionStatusSnapshots(collectionStatusSnapshotEntities);
+        }
+
+        if (getProcessorStatusSnapshots() != null) {
+            final List<ProcessorStatusSnapshotEntity> 
processorStatusSnapshotEntities = new ArrayList<>();
+            for (final ProcessorStatusSnapshotEntity 
processorStatusSnapshotEntity :  getProcessorStatusSnapshots() ) {
+                ProcessorStatusSnapshotEntity clone = 
processorStatusSnapshotEntity.clone();
+                clone.setId(processorStatusSnapshotEntity.getId());
+                processorStatusSnapshotEntities.add(clone);
+            }
+            other.setProcessorStatusSnapshots(processorStatusSnapshotEntities);
+        }
+
+        if (getRemoteProcessGroupStatusSnapshots() != null) {
+            final List<RemoteProcessGroupStatusSnapshotEntity> 
remoteProcessGroupStatusSnapshotEntities = new ArrayList<>();
+            for (final RemoteProcessGroupStatusSnapshotEntity 
remoteProcessGroupStatusSnapshotEntity :  
getRemoteProcessGroupStatusSnapshots() ) {
+                RemoteProcessGroupStatusSnapshotEntity clone = 
remoteProcessGroupStatusSnapshotEntity.clone();
+                clone.setId(remoteProcessGroupStatusSnapshotEntity.getId());
+                remoteProcessGroupStatusSnapshotEntities.add(clone);
+            }
+            
other.setRemoteProcessGroupStatusSnapshots(remoteProcessGroupStatusSnapshotEntities);
+        }
+
+        if (getInputPortStatusSnapshots() != null) {
+            final List<PortStatusSnapshotEntity> portStatusSnapshotEntities = 
new ArrayList<>();
+            for (final PortStatusSnapshotEntity portStatusSnapshotEntity :  
getInputPortStatusSnapshots()) {
+               PortStatusSnapshotEntity clone = 
portStatusSnapshotEntity.clone();
+               clone.setId(portStatusSnapshotEntity.getId());
+               portStatusSnapshotEntities.add(clone);
+            }
+            other.setInputPortStatusSnapshots(portStatusSnapshotEntities);
+        }
+
+        if (getOutputPortStatusSnapshots() != null) {
+            final List<PortStatusSnapshotEntity> portStatusSnapshotEntities = 
new ArrayList<>();
+            for (final PortStatusSnapshotEntity portStatusSnapshotEntity :  
getOutputPortStatusSnapshots()) {
+                PortStatusSnapshotEntity clone = 
portStatusSnapshotEntity.clone();
+                clone.setId(portStatusSnapshotEntity.getId());
+                portStatusSnapshotEntities.add(clone);
+            }

Review Comment:
   Minor optimization, it looks like the Port Status Snapshot creation could be 
use a shared method to create a copy.



##########
nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ProcessGroupStatusSnapshotDTO.java:
##########
@@ -563,28 +563,66 @@ public ProcessGroupStatusSnapshotDTO clone() {
 
         other.setProcessingNanos(getProcessingNanos());
 
-        
other.setConnectionStatusSnapshots(copy(getConnectionStatusSnapshots()));
-        other.setProcessorStatusSnapshots(copy(getProcessorStatusSnapshots()));
-        
other.setRemoteProcessGroupStatusSnapshots(copy(getRemoteProcessGroupStatusSnapshots()));
-        other.setInputPortStatusSnapshots(copy(getInputPortStatusSnapshots()));
-        
other.setOutputPortStatusSnapshots(copy(getOutputPortStatusSnapshots()));
+        if (getConnectionStatusSnapshots() != null) {

Review Comment:
   Using the `get` method here and in the for loop seems unnecessary when the 
member variable is directly accessible in this method.



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