FasterXML / FasterXML/jackson-module-kotlin

Missing empty constructor issue: deserialization breaking change from 2.17 to 2.18

Open
#846 24 comments 15 reactions 0 assignees View on GitHub
bug
Dominant language
Kotlin
Stars
1.2k
Forks
187
Avg merge
9h 48m
Merged PRs (30d)
16

Description

### Search before asking

- [X] I searched in the [issues](https://github.com/FasterXML/jackson-module-kotlin/issues) and found nothing similar.
- [X] I have confirmed that the same problem is not reproduced if I exclude the KotlinModule.
- [ ] I searched in the [issues of databind](https://github.com/FasterXML/jackson-databind/issues) and other modules used and found nothing similar.
- [ ] I have confirmed that the problem does not reproduce in Java and only occurs when using Kotlin and KotlinModule.

### Describe the bug

It appears that 2.18 introduced a change to the constructor detection, causing existing use cases to fail. I observed it in a case where a class extending a Map without an empty constructor can no longer be instantiated. See the test case example.

### To Reproduce

With jackson 2.18.0 onboard:
```kotlin
@Test
fun test() {
assertThrows {
jacksonObjectMapper().readValue("""{ "key":"value" }""")
}

assertDoesNotThrow {
jacksonObjectMapper().readValue("""{ "key":"value" }""")
}
}

// what was working prior to 2.18
class Old : TreeMap {
constructor(map: Map) : super(map)
}

// what has to be changed to work with 2.18
class New : TreeMap {
constructor() : super()
constructor(map: Map) : super(map)
}
```

### Expected behavior

Changes should be backward-compatible per the versioning standard (minor version changed).

### Versions

Kotlin:
Jackson-module-kotlin: 2.18.0
Jackson-databind: 2.18.0

### Additional context

I'm not 100% sure if this is a Kotlin module issue or not, as I operate in Kotlin codebase only and not invested enough to test it in plane java.
Generally, the fix to the issue is simple; the questionable part is that, if this is intentional, this is technically a breaking change in a minor version change.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.