Fix issue with prefilling Mapper and empty array values

This commit is contained in:
George Kalampokis 2022-03-15 17:55:40 +02:00
parent 563711eae4
commit 4e0402df95
1 changed files with 2 additions and 2 deletions

View File

@ -67,7 +67,7 @@ public class PrefillingMapper {
}
JsonNode valueNode = mapper.readTree(value);
List<String> parsedValues = new ArrayList<>();
if (valueNode.isArray() && (!valueNode.get(0).isTextual())) {
if (valueNode.isArray() && (valueNode.get(0) != null && !valueNode.get(0).isTextual())) {
if (prefillingMapping.getSubSource() == null || prefillingMapping.getSubSource().isEmpty()) {
throw new IllegalArgumentException("Source value is an array but no subSource field have been set");
}
@ -83,7 +83,7 @@ public class PrefillingMapper {
String parsedValue = null;
if (valueNode.isTextual()) {
parsedValue = valueNode.textValue().replace(trimRegex, "");
}else if (valueNode.isArray() && valueNode.get(0).isTextual()) {
}else if (valueNode.isArray() && (valueNode.get(0) != null && valueNode.get(0).isTextual())) {
List<String> values = new LinkedList<>();
for (int i = 0; i < valueNode.size(); i++) {
values.add(valueNode.get(i).textValue().replace(trimRegex, ""));