You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/07/20 16:45:06 UTC

[GitHub] [nifi] emiliosetiadarma opened a new pull request, #6227: NIFI-10048: changed Hashcode function in StandardFlowDifference to ac…

emiliosetiadarma opened a new pull request, #6227:
URL: https://github.com/apache/nifi/pull/6227

   …comodate missing identifiers in components, and added tests in TestFlowController that used flow.json files
   
   Still investigating what could cause identifiers to be null. Will follow up in this effort
   
   <!-- Licensed to the Apache Software Foundation (ASF) under one or more -->
   <!-- contributor license agreements.  See the NOTICE file distributed with -->
   <!-- this work for additional information regarding copyright ownership. -->
   <!-- The ASF licenses this file to You under the Apache License, Version 2.0 -->
   <!-- (the "License"); you may not use this file except in compliance with -->
   <!-- the License.  You may obtain a copy of the License at -->
   <!--     http://www.apache.org/licenses/LICENSE-2.0 -->
   <!-- Unless required by applicable law or agreed to in writing, software -->
   <!-- distributed under the License is distributed on an "AS IS" BASIS, -->
   <!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
   <!-- See the License for the specific language governing permissions and -->
   <!-- limitations under the License. -->
   
   # Summary
   
   [NIFI-10048](https://issues.apache.org/jira/browse/NIFI-10048)
   
   # Tracking
   
   Please complete the following tracking steps prior to pull request creation.
   
   ### Issue Tracking
   
   - [x] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created
   
   ### Pull Request Tracking
   
   - [x] Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000`
   - [x] Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000`
   
   ### Pull Request Formatting
   
   - [x] Pull Request based on current revision of the `main` branch
   - [x] Pull Request refers to a feature branch with one commit containing changes
   
   # Verification
   
   Please indicate the verification steps performed prior to pull request creation.
   
   ### Build
   
   - [x] Build completed using `mvn clean install -P contrib-check`
     - [x] JDK 8
     - [x] JDK 11
     - [x] JDK 17
   
   ### Licensing
   
   - [ ] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html)
   - [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files
   
   ### Documentation
   
   - [ ] Documentation formatting appears as expected in rendered files
   


-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] exceptionfactory commented on a diff in pull request #6227: NIFI-10048: changed Hashcode function in StandardFlowDifference to ac…

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on code in PR #6227:
URL: https://github.com/apache/nifi/pull/6227#discussion_r931552490


##########
nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowDifference.java:
##########
@@ -116,18 +116,18 @@ public boolean equals(final Object obj) {
 
         // If both flows have a component A with an instance identifier, the instance ID's must be the same.
         if (componentA != null && componentA.getInstanceIdentifier() != null && other.componentA != null && other.componentA.getInstanceIdentifier() != null
-            && !componentA.getInstanceIdentifier().equals(other.componentA.getInstanceIdentifier())) {
+                && !componentA.getInstanceIdentifier().equals(other.componentA.getInstanceIdentifier())) {
             return false;
         }
 
         // If both flows have a component B with an instance identifier, the instance ID's must be the same.
         if (componentB != null && componentB.getInstanceIdentifier() != null && other.componentB != null && other.componentB.getInstanceIdentifier() != null
-            && !componentB.getInstanceIdentifier().equals(other.componentB.getInstanceIdentifier())) {
+                && !componentB.getInstanceIdentifier().equals(other.componentB.getInstanceIdentifier())) {
             return false;
         }
 
         return Objects.equals(componentAId, otherComponentAId) && Objects.equals(componentBId, otherComponentBId)
-            && Objects.equals(description, other.description) && Objects.equals(type, other.type)
-            && Objects.equals(valueA, other.valueA) && Objects.equals(valueB, other.valueB);
+                && Objects.equals(description, other.description) && Objects.equals(type, other.type)
+                && Objects.equals(valueA, other.valueA) && Objects.equals(valueB, other.valueB);
     }
-}
+}

Review Comment:
   This file also contains a number of formatting changes, please revert so that the changes are scoped to the `hashCode()` method. Thanks!



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] exceptionfactory closed pull request #6227: NIFI-10048: changed Hashcode function in StandardFlowDifference to ac…

Posted by GitBox <gi...@apache.org>.
exceptionfactory closed pull request #6227: NIFI-10048: changed Hashcode function in StandardFlowDifference to ac…
URL: https://github.com/apache/nifi/pull/6227


-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] exceptionfactory commented on a diff in pull request #6227: NIFI-10048: changed Hashcode function in StandardFlowDifference to ac…

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on code in PR #6227:
URL: https://github.com/apache/nifi/pull/6227#discussion_r931195188


##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/VersionedFlowSynchronizer.java:
##########
@@ -384,7 +384,6 @@ private void synchronizeFlow(final FlowController controller, final DataFlow exi
 
     private FlowComparison compareFlows(final DataFlow existingFlow, final DataFlow proposedFlow, final PropertyEncryptor encryptor) {
         final DifferenceDescriptor differenceDescriptor = new StaticDifferenceDescriptor();
-

Review Comment:
   This change can be reverted



##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/conf/new-flow.json:
##########
@@ -0,0 +1 @@
+{"encodingVersion":{"majorVersion":2,"minorVersion":0},"maxTimerDrivenThreadCount":10,"registries":[],"parameterContexts":[],"controllerServices":[],"reportingTasks":[],"templates":[],"rootGroup":{"identifier":"2a2b649d-8538-3239-9965-536b5b993cc5","instanceIdentifier":"13c477b8-0182-1000-31df-454d42e70446","name":"NiFi Flow","comments":"","position":{"x":0.0,"y":0.0},"processGroups":[],"remoteProcessGroups":[],"processors":[],"inputPorts":[],"outputPorts":[],"connections":[],"labels":[],"funnels":[],"controllerServices":[],"variables":{},"defaultFlowFileExpiration":"0 sec","defaultBackPressureObjectThreshold":10000,"defaultBackPressureDataSizeThreshold":"1 GB","flowFileOutboundPolicy":"STREAM_WHEN_AVAILABLE","flowFileConcurrency":"UNBOUNDED","componentType":"PROCESS_GROUP"}}

Review Comment:
   It would be helpful to pretty-print these JSON flow definitions to make them easier to read for testing. Alternatively, is it possible to construct the flow definitions in test methods instead of external files?



##########
nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowComparator.java:
##########
@@ -129,7 +129,7 @@ private boolean compareComponents(final VersionedComponent componentA, final Ver
     }
 
     private boolean compareComponents(final VersionedComponent componentA, final VersionedComponent componentB, final Set<FlowDifference> differences,
-        final boolean compareName, final boolean comparePos, final boolean compareComments) {
+                                      final boolean compareName, final boolean comparePos, final boolean compareComments) {

Review Comment:
   The changes in this file appear to be limited to formatting, can you revert the changes?



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] exceptionfactory commented on a diff in pull request #6227: NIFI-10048: changed Hashcode function in StandardFlowDifference to ac…

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on code in PR #6227:
URL: https://github.com/apache/nifi/pull/6227#discussion_r931519799


##########
nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowComparator.java:
##########
@@ -624,4 +624,4 @@ private FlowDifference difference(final DifferenceType type, final VersionedComp
     private static interface ComponentComparator<T extends VersionedComponent> {
         void compare(T componentA, T componentB, Set<FlowDifference> differences);
     }
-}
+}

Review Comment:
   Thanks for making the updates @emiliosetiadarma, can you revert this change as well?



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] emiliosetiadarma commented on a diff in pull request #6227: NIFI-10048: changed Hashcode function in StandardFlowDifference to ac…

Posted by GitBox <gi...@apache.org>.
emiliosetiadarma commented on code in PR #6227:
URL: https://github.com/apache/nifi/pull/6227#discussion_r931477974


##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/conf/new-flow.json:
##########
@@ -0,0 +1 @@
+{"encodingVersion":{"majorVersion":2,"minorVersion":0},"maxTimerDrivenThreadCount":10,"registries":[],"parameterContexts":[],"controllerServices":[],"reportingTasks":[],"templates":[],"rootGroup":{"identifier":"2a2b649d-8538-3239-9965-536b5b993cc5","instanceIdentifier":"13c477b8-0182-1000-31df-454d42e70446","name":"NiFi Flow","comments":"","position":{"x":0.0,"y":0.0},"processGroups":[],"remoteProcessGroups":[],"processors":[],"inputPorts":[],"outputPorts":[],"connections":[],"labels":[],"funnels":[],"controllerServices":[],"variables":{},"defaultFlowFileExpiration":"0 sec","defaultBackPressureObjectThreshold":10000,"defaultBackPressureDataSizeThreshold":"1 GB","flowFileOutboundPolicy":"STREAM_WHEN_AVAILABLE","flowFileConcurrency":"UNBOUNDED","componentType":"PROCESS_GROUP"}}

Review Comment:
   Making the changes to have them set programmatically



##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/VersionedFlowSynchronizer.java:
##########
@@ -384,7 +384,6 @@ private void synchronizeFlow(final FlowController controller, final DataFlow exi
 
     private FlowComparison compareFlows(final DataFlow existingFlow, final DataFlow proposedFlow, final PropertyEncryptor encryptor) {
         final DifferenceDescriptor differenceDescriptor = new StaticDifferenceDescriptor();
-

Review Comment:
   Making the changes



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] emiliosetiadarma commented on a diff in pull request #6227: NIFI-10048: changed Hashcode function in StandardFlowDifference to ac…

Posted by GitBox <gi...@apache.org>.
emiliosetiadarma commented on code in PR #6227:
URL: https://github.com/apache/nifi/pull/6227#discussion_r931478247


##########
nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowComparator.java:
##########
@@ -129,7 +129,7 @@ private boolean compareComponents(final VersionedComponent componentA, final Ver
     }
 
     private boolean compareComponents(final VersionedComponent componentA, final VersionedComponent componentB, final Set<FlowDifference> differences,
-        final boolean compareName, final boolean comparePos, final boolean compareComments) {
+                                      final boolean compareName, final boolean comparePos, final boolean compareComments) {

Review Comment:
   Will revert the changes



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] exceptionfactory commented on a diff in pull request #6227: NIFI-10048: changed Hashcode function in StandardFlowDifference to ac…

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on code in PR #6227:
URL: https://github.com/apache/nifi/pull/6227#discussion_r933301917


##########
nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowDifference.java:
##########
@@ -89,8 +89,8 @@ public String toString() {
 
     @Override
     public int hashCode() {
-        return 31 + 17 * (componentA == null ? 0 : componentA.getIdentifier().hashCode()) +
-            17 * (componentB == null ? 0 : componentB.getIdentifier().hashCode()) +
+        return 31 + 17 * (componentA == null ? 0 : Objects.hash(componentA.getIdentifier())) +
+            17 * (componentB == null ? 0 : Objects.hash(componentB.getIdentifier())) +

Review Comment:
   This method should use Objects.`hashCode(Object o)` instead of Objects.`hash(Object... values)`. The `Objects.hash()` method delegates to `Arrays.hashCode()`, but all that is necessary is to use `Objects.hashCode()` to provide null-safe handling of `identifier`.
   ```suggestion
           return 31 + 17 * (componentA == null ? 0 : Objects.hashCode(componentA.getIdentifier())) +
               17 * (componentB == null ? 0 : Objects.hashCode(componentB.getIdentifier())) +
   ```



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] emiliosetiadarma commented on a diff in pull request #6227: NIFI-10048: changed Hashcode function in StandardFlowDifference to ac…

Posted by GitBox <gi...@apache.org>.
emiliosetiadarma commented on code in PR #6227:
URL: https://github.com/apache/nifi/pull/6227#discussion_r933433776


##########
nifi-registry/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowDifference.java:
##########
@@ -89,8 +89,8 @@ public String toString() {
 
     @Override
     public int hashCode() {
-        return 31 + 17 * (componentA == null ? 0 : componentA.getIdentifier().hashCode()) +
-            17 * (componentB == null ? 0 : componentB.getIdentifier().hashCode()) +
+        return 31 + 17 * (componentA == null ? 0 : Objects.hash(componentA.getIdentifier())) +
+            17 * (componentB == null ? 0 : Objects.hash(componentB.getIdentifier())) +

Review Comment:
   Hey David, thanks for the catch, will make those changes



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org