-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Enhance KotlinSerializer with value codecs for widening primitive conversion. #1301
base: master
Are you sure you want to change the base?
Conversation
…version. JAVA-5303
Kotlinx Json has a configuration to allow for lenient parsing: https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/json.md#lenient-parsing Should this be configurable? |
@rozza I think in this case it's better to be consistent with other codecs and also with the way numeric values are treated in MongoDB is basically interchangeable and compatible with each other, so long as there is no loss of precision or magnitude. |
@vbabanin can this come out of Draft now? |
JAVA-5303
<!-- MongoDB status: "False Positive", SpotBugs rank: 17 --> | ||
<Class name="org.bson.codecs.kotlinx.KotlinSerializerCodec$Companion"/> | ||
<Method name="~.*validateAnnotations.*"/> | ||
<Bug pattern="BC_BAD_CAST_TO_ABSTRACT_COLLECTION"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning is triggered by an implicit cast generated during Kotlin to Java bytecode compilation, which is not directly controllable in the source Kotlin code. As this casting is safely handled by the Kotlin compiler and does not reflect an actual error in our Kotlin source, we can suppress this warning.
@@ -34,8 +34,18 @@ import org.bson.BsonReader | |||
import org.bson.BsonReaderMark | |||
import org.bson.BsonType | |||
import org.bson.BsonValue | |||
import org.bson.codecs.BooleanCodec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we discussed not using codecs (so to not confuse the two concepts of codecs and kserializers. Instead use the NumberCodecHelper
directly (which is what the numeric codecs are doing in decode anyway).
JAVA-5303