Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change MKPE.parameter property to transient. #654

Merged
merged 1 commit into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the comment, there is a problem that deserialization destroys null safety.
However, considering compatibility and the low importance of deserialization, I think this approach is better.

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
Original file line number Diff line number Diff line change
@@ -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)
}
}