From 8b69890883e5b650d15ba9331738c845d8ffc631 Mon Sep 17 00:00:00 2001 From: Drew Stephens Date: Tue, 21 Apr 2020 13:14:07 -0400 Subject: [PATCH 1/5] Make MKPE descend from MismatchedInputException --- .../com/fasterxml/jackson/module/kotlin/Exceptions.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/Exceptions.kt b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/Exceptions.kt index a95d50643..0ad02e466 100644 --- a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/Exceptions.kt +++ b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/Exceptions.kt @@ -1,10 +1,14 @@ package com.fasterxml.jackson.module.kotlin +import com.fasterxml.jackson.core.JsonParser import com.fasterxml.jackson.databind.JsonMappingException -import java.io.Closeable +import com.fasterxml.jackson.databind.exc.MismatchedInputException import kotlin.reflect.KParameter /** - * Specialized [JsonMappingException] sub-class used to indicate that a mandatory Kotlin constructor parameter was missing or null. + * Specialized [JsonMappingException] sub-class used to indicate that a mandatory Kotlin constructor + * parameter was missing or null. */ -class MissingKotlinParameterException(val parameter: KParameter, val processor: Closeable? = null, val msg: String) : JsonMappingException(processor, msg) \ No newline at end of file +class MissingKotlinParameterException(val parameter: KParameter, + val processor: JsonParser? = null, + val msg: String) : MismatchedInputException(processor, msg) \ No newline at end of file From 0ecf39513a20d9d5c251fa29dfa656465815837b Mon Sep 17 00:00:00 2001 From: Drew Stephens Date: Tue, 21 Apr 2020 13:18:16 -0400 Subject: [PATCH 2/5] Add version note for MKPE parent exception change --- release-notes/VERSION-2.x | 1 + 1 file changed, 1 insertion(+) diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 38b99cd92..ea265aec2 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -10,6 +10,7 @@ Project: jackson-module-kotlin - Add Builder for KotlinModule #281: Hide singleton deserialization support behind a setting on the module, `singletonSupport` and enum `SingletonSupport`. Defaults to pre-2.10 behavior. +#321: Make MissingKotlinParameterException extend MismatchedInputException Kotlin updated to 1.3.61 From ee079d7beceb09f2425226da0aad90da091c7468 Mon Sep 17 00:00:00 2001 From: Drew Stephens Date: Wed, 22 Apr 2020 09:32:00 -0400 Subject: [PATCH 3/5] Add secondary constructor that still takes Closeable? --- .../com/fasterxml/jackson/module/kotlin/Exceptions.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/Exceptions.kt b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/Exceptions.kt index 0ad02e466..11a9d6336 100644 --- a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/Exceptions.kt +++ b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/Exceptions.kt @@ -3,6 +3,7 @@ package com.fasterxml.jackson.module.kotlin import com.fasterxml.jackson.core.JsonParser import com.fasterxml.jackson.databind.JsonMappingException import com.fasterxml.jackson.databind.exc.MismatchedInputException +import java.io.Closeable import kotlin.reflect.KParameter /** @@ -10,5 +11,11 @@ import kotlin.reflect.KParameter * parameter was missing or null. */ class MissingKotlinParameterException(val parameter: KParameter, - val processor: JsonParser? = null, - val msg: String) : MismatchedInputException(processor, msg) \ No newline at end of file + processor: JsonParser? = null, + msg: String) : MismatchedInputException(processor, msg) { + constructor( + parameter: KParameter, + processor: Closeable? = null, + msg: String + ) : this(parameter, processor as JsonParser, msg) +} From 762005915d958890620a88e7f59f29b27309ce19 Mon Sep 17 00:00:00 2001 From: Drew Stephens Date: Wed, 22 Apr 2020 15:03:47 -0400 Subject: [PATCH 4/5] Add deprecated annotation --- .../kotlin/com/fasterxml/jackson/module/kotlin/Exceptions.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/Exceptions.kt b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/Exceptions.kt index 11a9d6336..d52aa122f 100644 --- a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/Exceptions.kt +++ b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/Exceptions.kt @@ -13,6 +13,7 @@ import kotlin.reflect.KParameter class MissingKotlinParameterException(val parameter: KParameter, processor: JsonParser? = null, msg: String) : MismatchedInputException(processor, msg) { + @Deprecated("Use main constructor", ReplaceWith("MissingKotlinParameterException(KParameter, JsonParser?, String)")) constructor( parameter: KParameter, processor: Closeable? = null, From cc440fca80810d7ada68e47e00cd585a5ee2322a Mon Sep 17 00:00:00 2001 From: Drew Stephens Date: Wed, 22 Apr 2020 17:09:14 -0400 Subject: [PATCH 5/5] Add Mateusz Stefek as reporter --- release-notes/CREDITS-2.x | 3 +++ 1 file changed, 3 insertions(+) diff --git a/release-notes/CREDITS-2.x b/release-notes/CREDITS-2.x index f4cf3c66d..b2032dc13 100644 --- a/release-notes/CREDITS-2.x +++ b/release-notes/CREDITS-2.x @@ -41,3 +41,6 @@ Drew Stephens (dinomite@github) * Contributed fix for #281: KotlinObjectSingletonDeserializer fails to deserialize previously serialized JSON as it doesn't delegate deserializeWithType (2.11.0) + +Mateusz Stefek (MateuszStefek@github) +* Reported #321: Make MissingKotlinParameterException a descendant of MismatchedInputException