Skip to content

Commit

Permalink
NIFI-12323 Removed String Length Limits from JSON Flow Configuration
Browse files Browse the repository at this point in the history
- Configured StreamReadConstraints on the ObjectMapper used by StandardDataFlow

This closes #7985

Signed-off-by: David Handermann <exceptionfactory@apache.org>
(cherry picked from commit 940c927)
  • Loading branch information
bbende authored and exceptionfactory committed Nov 7, 2023
1 parent 20a75d2 commit 1818d43
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -152,9 +153,14 @@ private VersionedDataflow parseVersionedDataflow(final byte[] flow) {
}

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) {
Expand Down

0 comments on commit 1818d43

Please sign in to comment.