-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Merge pull request #682 from k163377/fix/617"
- Loading branch information
Showing
9 changed files
with
79 additions
and
37 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
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/com/fasterxml/jackson/module/kotlin/Exceptions.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,32 @@ | ||
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 | ||
|
||
/** | ||
* Specialized [JsonMappingException] sub-class used to indicate that a mandatory Kotlin constructor | ||
* parameter was missing or null. | ||
*/ | ||
@Deprecated( | ||
"It will be removed in jackson-module-kotlin 2.16. 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(@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/com/fasterxml/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 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) | ||
} | ||
} |
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