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/09/12 18:24:39 UTC

[GitHub] [nifi] nandorsoma opened a new pull request, #6408: Fix NullPointerException on updating empty ParameterContext property with NiFi Toolkit

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

   <!-- 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-10488](https://issues.apache.org/jira/browse/NIFI-10488)
   
   CLI throws an error when we are trying to set an empty property:
   ```
   ERROR: Error executing command 'set-param' : null 
   ```
   Command to test with:
   ```
   ./cli.sh nifi set-param -u http://localhost:8080/ -pcid 32d572a1-0183-1000-a811-ab916612b4af -pn emptyParam -pv newvalue
   ```
   
   # 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
     - [ ] JDK 11
     - [ ] 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] nandorsoma commented on a diff in pull request #6408: Fix NullPointerException on updating empty ParameterContext property with NiFi Toolkit

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


##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/SetParam.java:
##########
@@ -88,7 +88,7 @@ public VoidResult doExecute(final NiFiClient client, final Properties properties
             throw new IllegalArgumentException("A parameter value is required when creating a new parameter");
         }
 
-        if (existingParam.isPresent() && existingParam.get().getValue().equals(paramValue)) {

Review Comment:
   Kk, then I just updated the pr with your proposal @markap14. Thank you!



-- 
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] markap14 merged pull request #6408: NIFI-10488 Fix NullPointerException on updating empty ParameterContext property with NiFi Toolkit

Posted by GitBox <gi...@apache.org>.
markap14 merged PR #6408:
URL: https://github.com/apache/nifi/pull/6408


-- 
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] markap14 commented on a diff in pull request #6408: Fix NullPointerException on updating empty ParameterContext property with NiFi Toolkit

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


##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/SetParam.java:
##########
@@ -88,7 +88,7 @@ public VoidResult doExecute(final NiFiClient client, final Properties properties
             throw new IllegalArgumentException("A parameter value is required when creating a new parameter");
         }
 
-        if (existingParam.isPresent() && existingParam.get().getValue().equals(paramValue)) {

Review Comment:
   Unclear to me at this point if the CLI supports setting a null value, but it probably should. If not, we may well add that in at some point, so makes sense to go ahead and support that at this point, anyway.



-- 
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] markap14 commented on a diff in pull request #6408: Fix NullPointerException on updating empty ParameterContext property with NiFi Toolkit

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


##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/SetParam.java:
##########
@@ -88,7 +88,7 @@ public VoidResult doExecute(final NiFiClient client, final Properties properties
             throw new IllegalArgumentException("A parameter value is required when creating a new parameter");
         }
 
-        if (existingParam.isPresent() && existingParam.get().getValue().equals(paramValue)) {

Review Comment:
   Yeah sorry, @nandorsoma , I didn't mean to imply that settings to null via CLI should work now, or that we should support it in this Jira. Just that `Objects.equals` makes the most sense, in order to consider the possibility of either value being null :) I don't think we need to address the issue of issuing null's in this PR.



-- 
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] markap14 commented on a diff in pull request #6408: Fix NullPointerException on updating empty ParameterContext property with NiFi Toolkit

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


##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/SetParam.java:
##########
@@ -88,7 +88,7 @@ public VoidResult doExecute(final NiFiClient client, final Properties properties
             throw new IllegalArgumentException("A parameter value is required when creating a new parameter");
         }
 
-        if (existingParam.isPresent() && existingParam.get().getValue().equals(paramValue)) {

Review Comment:
   This will address the case of a null value getting set to a non-null value.
   But what about the opposite? If you wanted to set a populated value to a null? We'd get a NPE in that case, no?
   Recommend using `Objects.equals` to check equality instead. I.e., `Objects.equals(existingParam.get().getValue(), paramValue)`



-- 
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] nandorsoma commented on a diff in pull request #6408: Fix NullPointerException on updating empty ParameterContext property with NiFi Toolkit

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


##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/SetParam.java:
##########
@@ -88,7 +88,7 @@ public VoidResult doExecute(final NiFiClient client, final Properties properties
             throw new IllegalArgumentException("A parameter value is required when creating a new parameter");
         }
 
-        if (existingParam.isPresent() && existingParam.get().getValue().equals(paramValue)) {

Review Comment:
   Kk, then I just updated with your proposal @markap14. Thank you!



-- 
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] markap14 commented on pull request #6408: NIFI-10488 Fix NullPointerException on updating empty ParameterContext property with NiFi Toolkit

Posted by GitBox <gi...@apache.org>.
markap14 commented on PR #6408:
URL: https://github.com/apache/nifi/pull/6408#issuecomment-1245685706

   Thanks @nandorsoma merged to main


-- 
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] nandorsoma commented on a diff in pull request #6408: Fix NullPointerException on updating empty ParameterContext property with NiFi Toolkit

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


##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/SetParam.java:
##########
@@ -88,7 +88,7 @@ public VoidResult doExecute(final NiFiClient client, final Properties properties
             throw new IllegalArgumentException("A parameter value is required when creating a new parameter");
         }
 
-        if (existingParam.isPresent() && existingParam.get().getValue().equals(paramValue)) {

Review Comment:
   omg yes, totally forgot about that use-case



-- 
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] nandorsoma commented on a diff in pull request #6408: Fix NullPointerException on updating empty ParameterContext property with NiFi Toolkit

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


##########
nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/SetParam.java:
##########
@@ -88,7 +88,7 @@ public VoidResult doExecute(final NiFiClient client, final Properties properties
             throw new IllegalArgumentException("A parameter value is required when creating a new parameter");
         }
 
-        if (existingParam.isPresent() && existingParam.get().getValue().equals(paramValue)) {

Review Comment:
   So I tested it. We can avoid the null pointer exception with your proposal, but it is not enough to set null to a value. On the ParameterDTO, there is a valueRemoved flag that we also need to set true. Then the value will be updated to null on the NiFi side.
   Though there is a check that only allows to update a value when the new value is not null. I don't know that it was a requirement or it is another bug: https://github.com/apache/nifi/blob/5b1034072b207a844ecbd2e8f0da8bf7981a9d24/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/SetParam.java#L100
   
   To summarize, without my change:
   - CLI throws an error when we are trying to create a new Parameter with null value. On the other hand, through NiFi UI, it is possible.
   - CLI silently fails to update the Parameter to null, which is also possible through NiFi UI.
   
   Do you want me to solve these problems along with the original problem, or do you want to create a separate ticket for that? I'm happy to do them in this one, but at least we shouldn't silently fail.



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