-
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.
Merge pull request #720 from k163377/fix/617
Revert "Merge pull request #682 from k163377/fix/617" with comment correction.
- Loading branch information
Showing
10 changed files
with
88 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
41 changes: 41 additions & 0 deletions
41
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,41 @@ | ||
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 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/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