FasterXML / FasterXML/jackson-databind
JsonSetter.contentNulls propagates unexpectedly into nested structures
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 1.5k
- Avg merge
- 3d 6h
- Merged PRs (30d)
- 28
Description
### Search before asking
- [x] I searched in the [issues](https://github.com/FasterXML/jackson-databind/issues) and found nothing similar.
### Describe the bug
`JsonSetter.contentNulls` should fundamentally only apply to the explicitly provided parameters.
That is, if this specification is applied to a parameter like `List>`, `[null]` should be rejected, but `[[null]]` should be allowed.
However, in practice, `[[null]]` is rejected.
### Version Information
3.1.0
### Reproduction
```java
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class Kotlin1064Test {
record Dst(
@JsonSetter(contentNulls = Nulls.FAIL)
List> foo
) {}
@Test
public void test() {
var mapper = JsonMapper.builder().build();
assertThrows(InvalidNullException.class, () -> mapper.readValue("{\"foo\":[null]}", Dst.class));
// fails
assertDoesNotThrow(() -> mapper.readValue("{\"foo\":[[null]]}", Dst.class));
}
}
```
### Expected behavior
_No response_
### Additional context
This relates to the following issues.
https://github.com/FasterXML/jackson-module-kotlin/issues/1064
While it's hard to say what behavior is ideal, having `Nulls.FAIL` applied to the entire nested structure feels a bit cumbersome to handle.
Also, I don't have a specific design in mind yet, but I feel that fundamentally, we might need to change the structure of `JsonSetter`.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.