NIFI-13577 Corrected null handling in Parameter Value Mapper (#9107)

This commit is contained in:
David Handermann 2024-07-24 07:01:41 -05:00 committed by GitHub
parent c31fb9d373
commit 11fdc44fb9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View File

@ -48,7 +48,9 @@ public class StandardParameterValueMapper implements ParameterValueMapper {
final ParameterDescriptor descriptor = parameter.getDescriptor();
final String mapped;
if (parameter.isProvided()) {
if (value == null) {
mapped = null;
} else if (parameter.isProvided()) {
mapped = PROVIDED_MAPPING;
} else if (descriptor.isSensitive()) {
if (sensitiveValueEncryptor == null) {

View File

@ -25,6 +25,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
@ExtendWith(MockitoExtension.class)
class TestStandardParameterValueMapper {
@ -79,6 +80,15 @@ class TestStandardParameterValueMapper {
assertNotEquals(StandardParameterValueMapper.PROVIDED_MAPPING, mapped);
}
@Test
void testGetMappedSensitiveNotProvidedNullValue() {
final Parameter parameter = getParameter(true, false);
final String mapped = mapper.getMapped(parameter, null);
assertNull(mapped);
}
private Parameter getParameter(final boolean sensitive, final boolean provided) {
final ParameterDescriptor descriptor = new ParameterDescriptor.Builder().name(NAME).sensitive(sensitive).build();
return new Parameter(descriptor, VALUE, null, provided);