[ 
https://issues.apache.org/jira/browse/NIFI-7242?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17056302#comment-17056302
 ] 

Mark Payne commented on NIFI-7242:
----------------------------------

Looking into this, it looks like the behavior that is occurring is slightly 
different than is laid out in the description. The Controller Service appears 
to be properly Disabled and Re- Enabled. However, the AvroSchemaRegistry 
compiles the schemas in the `onPropertyModified` method:
{code:java}
public void onPropertyModified(final PropertyDescriptor descriptor, final 
String oldValue, final String newValue) {
    if(descriptor.isDynamic()) {
        // Dynamic property = schema, validate it
        if (newValue == null) {
            recordSchemas.remove(descriptor.getName());
        } else {
            try {
                // Use a non-strict parser here, a strict parse can be done (if 
specified) in customValidate().
                final Schema avroSchema = new 
Schema.Parser().setValidate(false).parse(newValue);
                final SchemaIdentifier schemaId = 
SchemaIdentifier.builder().name(descriptor.getName()).build();
                final RecordSchema recordSchema = 
AvroTypeUtil.createSchema(avroSchema, newValue, schemaId);
                recordSchemas.put(descriptor.getName(), recordSchema);
            } catch (final Exception e) {
                // not a problem - the service won't be valid and the 
validation message will indicate what is wrong.
            }
        }
    }
}
 {code}
Currently, changing the value of a Parameter does not trigger 
`onPropertyModified` to be called. However, I do think it should, as the value 
of the property is definitely changing. Will look into making these updates.

> Parameters update not taken into account in controller services
> ---------------------------------------------------------------
>
>                 Key: NIFI-7242
>                 URL: https://issues.apache.org/jira/browse/NIFI-7242
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Core Framework
>            Reporter: Pierre Villard
>            Assignee: Mark Payne
>            Priority: Blocker
>             Fix For: 1.12.0, 1.11.4
>
>         Attachments: parametersIssue.xml
>
>
> There is a bug with the parameters when used in Controller Services:
>  * when updating a parameter that is referenced in a controller service (in 
> this case avro schema registry), changing the value of the parameter does not 
> seem to trigger the restart of the controller service
>  * even if I do restart the components manually, the old value of the 
> parameter is still used... NiFi restart is the only way to get the new value 
> applied
> With the supplied template, create a Parameter Context with schema =
> {code:java}
> {
>   "type" : "record",
>   "name" : "myData",
>   "namespace" : "myLine",
>   "fields" : [
>     {
>       "name" : "myField1",
>       "type" : "string"
>     }
>   ]
> }
> {code}
> The AvroSchemaRegistry contains the schema with:
> schema => #\{schema}
> Get everything running: output data has only one column. Then update the 
> Parameter Context to have schema =
> {code:java}
> {
>   "type" : "record",
>   "name" : "myData",
>   "namespace" : "myLine",
>   "fields" : [
>     {
>       "name" : "myField1",
>       "type" : "string"
>     }, {
>       "name" : "myField2",
>       "type" : "string"
>     }
>   ]
> }
> {code}
> Output data has still one column only when it should have two with the new 
> schema.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to