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

MissingKotlinParameterException contains non-serializable KParameterImpl, breaking Throwable contract #572

Closed
ghost opened this issue Jun 15, 2022 · 6 comments
Labels
2.16 For issues planned for 2.16 bug

Comments

@ghost
Copy link

ghost commented Jun 15, 2022

Describe the bug

This bug is an offspring of spring-projects/spring-kafka#2306

As described there spring-kafka tries to serialize exceptions, which fails with

java.lang.RuntimeException: Could not deserialize type java.io.NotSerializableException with message kotlin.reflect.jvm.internal.KParameterImpl failure: kotlin.reflect.jvm.internal.KParameterImpl

To Reproduce

  • Create an instance of com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException
  • Create an ObjectOutputStream and try to write the exception object into the stream

Expected behavior

As MissingKotlinParameterException implements Serializable it should be serializable without any execptions.

Three options:
a) make KParameter property transient
b) implement special handling of non-serializable properties by implemeting writeObject/readObject
c) Request the kotlin people to implement KParameter classes as serializable

Versions
Kotlin: 1.7.0
Jackson-module-kotlin: 2.13.3
Jackson-databind: 2.13.3

@k163377
Copy link
Contributor

k163377 commented Mar 14, 2023

We are considering deprecating MissingKotlinParameterException in 2.16.
See #617 for details.

@cowtowncoder
Copy link
Member

Aside from deprecation, if reference is directly from MKPR, perhaps that reference could be changed to transient to avoid the issue?

k163377 added a commit to k163377/jackson-module-kotlin that referenced this issue Mar 21, 2023
@k163377
Copy link
Contributor

k163377 commented Mar 21, 2023

@cowtowncoder
It looks a good idea.
PR created.

@k163377
Copy link
Contributor

k163377 commented Mar 21, 2023

@jeromewaibel
The fix we are trying to do will not allow us to read the parameter property when deserialized.
#654 (comment)

Would this be a problem in your use case?
I am not aware of the details of the original problem and would appreciate your confirmation.

@ghost
Copy link
Author

ghost commented Mar 21, 2023

@k163377 This should be fine for me.

@k163377
Copy link
Contributor

k163377 commented Mar 22, 2023

#654 has been merged.
This issue is closed as resolved.

@k163377 k163377 closed this as completed Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.16 For issues planned for 2.16 bug
Projects
None yet
Development

No branches or pull requests

2 participants