FasterXML / FasterXML/jackson-module-kotlin
Boolean property setter is skipped if name isX prefixed
- 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 searched in the [issues of databind](https://github.com/FasterXML/jackson-databind/issues) and other modules used and found nothing similar.
- [X] I have confirmed that the problem only occurs when using Kotlin.
### Describe the bug
Jackson will not call property setter for boolean properties if the name is prefixed with isX.
Value is still assigned, which makes me suspect that it is assigning value to the backing field directly instead.
### To Reproduce
```kotlin
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import org.junit.Assert
import org.junit.Test
class ReadTest {
class Dummy {
var isAlive: Boolean? = null
set(value) {
field = value
setterUsed = true
}
var setterUsed = false
}
@Test
fun readPrefixedValueTest() {
val objectMapper = jacksonObjectMapper()
val dummy = objectMapper.readValue("{ \"isAlive\": true }")
Assert.assertTrue(dummy.setterUsed)
}
}
```
### Expected behavior
When running the reproduction case then the test should succeed.
The setter of isAlive property should be called.
### Versions
Kotlin: 1.9.23
Jackson-module-kotlin: 2.17.1
### Additional context
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.