Skip to content

Commit

Permalink
Merge pull request #654 from k163377/temp-fix-#572
Browse files Browse the repository at this point in the history
Change MKPE.parameter property to transient.
  • Loading branch information
k163377 committed Mar 22, 2023
2 parents 5ecac2e + d291b43 commit cf23637
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions pom.xml
Expand Up @@ -223,6 +223,7 @@
-->
<exclude>com.fasterxml.jackson.module.kotlin.ReflectionCache</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.TypesKt</exclude>
<exclude>com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException</exclude>
</excludes>
</parameter>
</configuration>
Expand Down
Expand Up @@ -18,7 +18,9 @@ import kotlin.reflect.KParameter
),
DeprecationLevel.WARNING
)
class MissingKotlinParameterException(val parameter: KParameter,
// When deserialized by the JDK, the parameter property will be null, ignoring nullability.
// This is a temporary workaround for #572 and we will eventually remove this class.
class MissingKotlinParameterException(@Transient val parameter: KParameter,
processor: JsonParser? = null,
msg: String) : MismatchedInputException(processor, msg) {
@Deprecated("Use main constructor", ReplaceWith("MissingKotlinParameterException(KParameter, JsonParser?, String)"))
Expand Down
@@ -0,0 +1,20 @@
package com.fasterxml.jackson.module.kotlin

import org.junit.Test
import kotlin.test.assertNotNull
import kotlin.test.assertNull

class MissingKotlinParameterExceptionTest {
@Test
fun jdkSerializabilityTest() {
val param = ::MissingKotlinParameterException.parameters.first()
val ex = MissingKotlinParameterException(param, null, "test")

val serialized = jdkSerialize(ex)
val deserialized = jdkDeserialize<MissingKotlinParameterException>(serialized)

assertNotNull(deserialized)
// see comment at MissingKotlinParameterException
assertNull(deserialized.parameter)
}
}

0 comments on commit cf23637

Please sign in to comment.