rsocket / rsocket-kotlin

RSocket Kotlin multi-platform implementation
http://rsocket.io
Apache License 2.0
552 stars 37 forks source link

Critical compatibility issue in Kotlin implementation due to MIME type serialization mismatch #260

Closed akowal closed 6 months ago

akowal commented 7 months ago

The current serialization of custom MIME types in Kotlin's RSocket implementation is not compatible with other implementations. The issue lies in the handling of the MIME type name's size during serialization and deserialization. Specifically, the Kotlin implementation directly writes the length of the MIME type name as it is: https://github.com/rsocket/rsocket-kotlin/blob/2239c5ca176694effbd803643d0179e79f76be3f/rsocket-core/src/commonMain/kotlin/io/rsocket/kotlin/frame/io/mimeType.kt#L50

Contrarily, other RSocket implementations such as Go and Java adjust the MIME type name length by decreasing it by one when writing and increasing it by one when reading:

This discrepancy makes Kotlin implementation incompatible with all other implementations.