-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'FasterXML/2.16'
- Loading branch information
Showing
9 changed files
with
87 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package tools.jackson.module.kotlin | ||
|
||
import tools.jackson.core.JsonParser | ||
import tools.jackson.databind.exc.MismatchedInputException | ||
import java.io.Closeable | ||
import kotlin.reflect.KParameter | ||
|
||
/** | ||
* Specialized [JsonMappingException] sub-class used to indicate that a mandatory Kotlin constructor | ||
* parameter was missing or null. | ||
*/ | ||
@Deprecated( | ||
"It is recommended that MismatchedInputException be referenced when possible," + | ||
" as the change is discussed for 2.17 and later." + | ||
" See #617 for details.", | ||
ReplaceWith( | ||
"MismatchedInputException", | ||
"com.fasterxml.jackson.databind.exc.MismatchedInputException" | ||
), | ||
DeprecationLevel.WARNING | ||
) | ||
// 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( | ||
@property:Deprecated( | ||
"KParameter is not serializable and will be removed in 2.17 or later. See #572 for details.", | ||
level = DeprecationLevel.WARNING | ||
) | ||
@Transient | ||
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, | ||
msg: String | ||
) : this(parameter, processor as JsonParser, msg) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/test/kotlin/tools/jackson/module/kotlin/MissingKotlinParameterExceptionTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package tools.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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters