Closed i-walker closed 2 years ago
This is awesome! Thanks heaps @i-walker !! 🙌
Before I create a new issue, just to make sure:
Does this PR (the upgrade and small fixes with it) address a test like this?
@Test
fun basicOptionParsing() {
val mapper = ObjectMapper()
.registerKotlinModule()
.registerArrowModule()
val optType = mapper.typeFactory.constructParametricType(
Option::class.java,
String::class.java
)
val nullToOption = mapper.readValue<Option<String>>("null", optType)
println(nullToOption)
Assertions.assertEquals(none<String>(), nullToOption, "null didn't parse to none()")
val valueToOption = mapper.readValue<Option<String>>("\"value\"", optType)
println(valueToOption)
Assertions.assertEquals(Some("value"), valueToOption, "\"value\" didn't parse to some()")
}
I recently found that the latest versions released of all related projects (see list below) cannot satisfy these expectations, and I'm guessing this PR will fix it. Versions:
io.arrow-kt:arrow-core:1.0.6-alpha.1
io.arrow-kt:arrow-integrations-jackson-module:0.13.2
jackson-*:2.13.2
If I change jackson to 2.12.6
, then it passes.
I'm also guessing this has to do with what is mentioned in the changelogs for Jackson 2.13:
Fix for databind#3271 to remove unintended coercion of JSON null into Java String "null" (in context of reading Type Id) had the downstream effect of breakage for DropWizard (reported as databind#3313). New behavior is considered correct and will remain in 2.13 and later versions.
resolves #70