mirror of https://github.com/apache/nifi.git
NIFI-14016 Resolved issue for onPropertyModified() where oldValue was always null (#9560)
NIFI-14016 Resolved issue for onPropertyModified() where oldValue was always null (#9560)
This commit is contained in:
parent
82fe051413
commit
39aa106943
|
@ -555,10 +555,11 @@ public abstract class AbstractComponentNode implements ComponentNode {
|
|||
|
||||
// Keep setProperty/removeProperty private so that all calls go through setProperties
|
||||
private void setProperty(final PropertyDescriptor descriptor, final PropertyConfiguration propertyConfiguration, final Function<PropertyDescriptor, PropertyConfiguration> valueToCompareFunction) {
|
||||
final PropertyConfiguration propertyModComparisonValue = valueToCompareFunction.apply(descriptor);
|
||||
|
||||
// Remove current PropertyDescriptor to force updated instance references
|
||||
final PropertyConfiguration removed = properties.remove(descriptor);
|
||||
|
||||
final PropertyConfiguration propertyModComparisonValue = valueToCompareFunction.apply(descriptor);
|
||||
properties.put(descriptor, propertyConfiguration);
|
||||
final String effectiveValue = propertyConfiguration.getEffectiveValue(getParameterContext());
|
||||
final String resolvedValue = resolveAllowableValue(effectiveValue, descriptor);
|
||||
|
|
|
@ -306,6 +306,37 @@ public class TestAbstractComponentNode {
|
|||
assertFalse(updatedPropertyDescriptor.isSensitive());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetPropertiesPropertyModified() {
|
||||
final String propertyValueModified = PROPERTY_VALUE + "-modified";
|
||||
final List<PropertyModification> propertyModifications = new ArrayList<>();
|
||||
final AbstractComponentNode node = new LocalComponentNode() {
|
||||
@Override
|
||||
protected void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) {
|
||||
propertyModifications.add(new PropertyModification(descriptor, oldValue, newValue));
|
||||
super.onPropertyModified(descriptor, oldValue, newValue);
|
||||
}
|
||||
};
|
||||
|
||||
final Map<String, String> properties = new HashMap<>();
|
||||
properties.put(PROPERTY_NAME, PROPERTY_VALUE);
|
||||
node.setProperties(properties);
|
||||
|
||||
assertEquals(1, propertyModifications.size());
|
||||
PropertyModification mod = propertyModifications.get(0);
|
||||
assertNull(mod.getPreviousValue());
|
||||
assertEquals(PROPERTY_VALUE, mod.getUpdatedValue());
|
||||
propertyModifications.clear();
|
||||
|
||||
properties.put(PROPERTY_NAME, propertyValueModified);
|
||||
node.setProperties(properties);
|
||||
|
||||
assertEquals(1, propertyModifications.size());
|
||||
mod = propertyModifications.get(0);
|
||||
assertEquals(PROPERTY_VALUE, mod.getPreviousValue());
|
||||
assertEquals(propertyValueModified, mod.getUpdatedValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetPropertiesSensitiveDynamicPropertyNames() {
|
||||
final AbstractComponentNode node = new LocalComponentNode();
|
||||
|
|
Loading…
Reference in New Issue