-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
type: enhancementNew feature or requestNew feature or request
Description
Feature description
With Jackson 2.15 a new StreamReadConstraints
was added which limit the maximum size of certain primitive JSON values. In our application we sometimes receive a String within a JSON message which exceeds the default maximum string length now. Having easy configuration of these stream read constraints would be very helpful for us.
Right now, I think the only way to use something other than the default values is to implement a method like this to override the default JsonFactory created by Micronaut:
@Primary
@Requires(beans = JacksonConfiguration.class)
@Singleton
@BootstrapContextCompatible
public JsonFactory jsonFactory(JacksonConfiguration jacksonConfiguration) {
final TSFBuilder<?, ?> jsonFactoryBuilder = JsonFactory.builder();
StreamReadConstraints streamReadConstraints = StreamReadConstraints.builder()
.maxStringLength(20 * 1024 * 1024).build()
jsonFactoryBuilder.streamReadConstraints(streamReadConstraints)
jacksonConfiguration.getFactorySettings().forEach(jsonFactoryBuilder::configure);
return jsonFactoryBuilder.build();
}
Metadata
Metadata
Assignees
Labels
type: enhancementNew feature or requestNew feature or request