NIFI-12323 Removed String Length Limits from JSON Flow Configuration

- Configured StreamReadConstraints on the ObjectMapper used by StandardDataFlow

This closes #7985

Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
Bryan Bende 2023-11-06 11:52:37 -05:00 committed by exceptionfactory
parent a89fb17f9f
commit 940c9276c5
No known key found for this signature in database
GPG Key ID: 29B6A52D2AAE8DBA
1 changed files with 6 additions and 0 deletions

View File

@ -16,6 +16,7 @@
*/
package org.apache.nifi.cluster.protocol;
import com.fasterxml.jackson.core.StreamReadConstraints;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
@ -152,9 +153,14 @@ public class StandardDataFlow implements Serializable, DataFlow {
}
try {
final StreamReadConstraints streamReadConstraints = StreamReadConstraints.builder()
.maxStringLength(Integer.MAX_VALUE)
.build();
final ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(objectMapper.getTypeFactory()));
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.getFactory().setStreamReadConstraints(streamReadConstraints);
return objectMapper.readValue(flow, VersionedDataflow.class);
} catch (final Exception e) {