New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
not-null requirement ignored for primitives in data classes #242
Comments
I'm also hitting this. |
|
I think that it should be possible to make Kotlin-specific |
I've hit this as well :( Any work on this? |
Is this issue the content of this PR repair? #41 Just configure Jackson will solve the problem jacksonObjectMapper().enable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES) You can simply configure it in spring spring:
jackson:
deserialization:
FAIL_ON_NULL_FOR_PRIMITIVES: true |
This is the default behavior of @cowtowncoder |
I think my only comment is that if Kotlin module could determine "requiredness" for properties, that could be used to force checks.
and for core Jackson checks for |
It was closed as a duplicate of FasterXML/jackson-databind#3392 |
I share a override fun refineDeserializationType(config: MapperConfig<*>, a: Annotated, baseType: JavaType): JavaType {
return if (a is AnnotatedParameter && baseType.isPrimitive) {
// As a workaround to the problem reported below,
// if the parameter is a primitive type, deserialize it as a wrapper type.
// https://github.com/FasterXML/jackson-module-kotlin/issues/242
config.typeFactory.constructType(baseType.rawClass.kotlin.javaObjectType)
} else {
baseType
}
} |
When deserializing a data class with primitive types, the default value for that java primitive type is used instead of throwing an IllegalArgumentException or MissingKotlinParameterException.
Steps to reproduce
The text was updated successfully, but these errors were encountered: