NIFI-16114 Fix version change bug when controller service property has a parameter reference - #11432
Conversation
233d128 to
493021a
Compare
pvillard31
left a comment
There was a problem hiding this comment.
Can you make sure that commit/PR follows the rules for the checks to execute properly? Also, did you consider a system test for it?
@pvillard31 thanks for having a look. I've added a system test and I fixed up the commit message and PR title to match the rules. |
|
|
||
| final String proposedValue = proposedProperties.get(propertyName); | ||
| final ParameterParser parameterParser = new ExpressionLanguageAgnosticParameterParser(); | ||
| final boolean proposedReferencingParameter = parameterParser.parseTokens(proposedValue).iterator().hasNext(); |
There was a problem hiding this comment.
proposedReferencingParameter is only read inside the referencesService branch. Could the parseTokens call move into that branch so non controller service properties are not parsed?
There was a problem hiding this comment.
Changed it so that proposedReferencingParameter is a function call and its last in the && chain so it will be short circuited if its non-service parameter. I organized it this way so that there is just one default else case where we assign proposedValue to value
|
|
||
| final String proposedValue = proposedProperties.get(propertyName); | ||
| final ParameterParser parameterParser = new ExpressionLanguageAgnosticParameterParser(); | ||
| final boolean proposedReferencingParameter = parameterParser.parseTokens(proposedValue).iterator().hasNext(); |
There was a problem hiding this comment.
Would toReferenceList().isEmpty() be more precise here than iterator().hasNext(), since the iterator also returns true for escape only tokens such as ##?
There was a problem hiding this comment.
Sorry for going MIA, I am back now. Im not opposed to either of the methods that return the list, I just wanted to clarify whether one could be empty while the other isnt. toList returns the token list while toReferencList returns the referenceList.
There was a problem hiding this comment.
Looks like toReferenceList is the one I want anyway, It will filter out tokens that are not a parameter reference.
| } | ||
|
|
||
| @Test | ||
| @SuppressWarnings("unchecked") |
There was a problem hiding this comment.
The test class already has a shared type safe propertiesCaptor field built with ArgumentCaptor.captor(). Could the new tests reuse it (or use captor()) so the @SuppressWarnings(unchecked) is not needed?
There was a problem hiding this comment.
When I remove the annotation I get a warning about ArgumentCaptor.forClass(Map.class);
There was a problem hiding this comment.
I believe the clean fix is to replace ArgumentCaptor.forClass(Map.class) with the type-safe ArgumentCaptor.captor() (already used in the class).
There was a problem hiding this comment.
Done, thanks for the hint.
525ac67 to
7d15d0b
Compare
|
@pvillard31 I responded to your comments and resolved a merge conflict with a similar test you added on the IT file. Looks like you resolved a bug in a similar area but it doesn't override this fix right? |
bd42f55 to
9e3c251
Compare
…arameter dereference during version upgrade and fix typing in a unit test to remove @SuppressWarnings(unchecked)

Summary
NIFI-16114 Fix version change bug that caused the controller service properties which have parameter values to have those parameters dereferenced leading to immediate "local changes" in my versioned flow.
Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000NIFI-00000VerifiedstatusPull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
./mvnw clean install -P contrib-checkLicensing
LICENSEandNOTICEfilesDocumentation