esensar / kotlinx-serialization-msgpack

MsgPack support for kotlinx.serialization -- msgpack.org[kotlinx.serialization]
https://www.ensarsarajcic.com/kotlinx-serialization-msgpack/
MIT License
44 stars 9 forks source link

possible manifest incompatibility with maven? #55

Closed jnorthrup closed 3 years ago

jnorthrup commented 3 years ago

possible manifest incompatibility with maven?

I am using maven, and maven can find the jarfiles on maven central, however nothing i do can get these to import in 1.6.0M1 for a jvm project.

image

esensar commented 3 years ago

I will have to check it out tomorrow, I am not sure if I will have time today. Can you check if it works for 1.5.30 in the meantime?

esensar commented 3 years ago

There seems to be an issue with artifacts of newer versions... You can use version 0.2.1 in the meantime (be sure not to drop out the jvm part, it is required when using maven):

        <dependency>
            <groupId>com.ensarsarajcic.kotlinx</groupId>
            <artifactId>serialization-msgpack-jvm</artifactId>
            <version>0.2.1</version>
        </dependency>

I will try to resolve this and I will hopefully release version 0.4.1 with the fix soon.

jnorthrup commented 3 years ago

much appreciated. msgpack is my first choice but i switched tracks to json since posting this for stubbing in the serde stuff

esensar commented 3 years ago

Fix is available in version 0.4.1, which is now available on Maven Central.

jnorthrup commented 3 years ago

looks like Pair is unimpl in fromByteArray ?

the pom:

https://gitlab.com/jnorthrup1/GardenKollektion/-/blob/main/gk-agent/pom.xml

the minimum possible testcase:


import com.ensarsarajcic.kotlinx.serialization.msgpack.MsgPack
import junit.framework.TestCase
import kotlinx.serialization.decodeFromByteArray
import kotlinx.serialization.encodeToByteArray
import java.nio.ByteBuffer

typealias ReifiedMessage = Pair<List<Pair<String, String>>, String>

val debug = { }

fun send(event: ReifiedMessage) =
    ByteBuffer.wrap(MsgPack.Default.encodeToByteArray(event))

fun recv(ser: ByteBuffer): ReifiedMessage {
    val byteArray = ByteArray(ser.remaining())
    ser.put(byteArray)
    val decodeFromByteArray = MsgPack.Default.decodeFromByteArray<ReifiedMessage>(byteArray)
    debug()
    return decodeFromByteArray
}

class SmMsgPackTest : TestCase() {

//    val sm1: SimpleMessage = _v["Alice" t2 "Bob",
//            "Charley" t2 "Delta"] t2 "Random message Body here"
//    fun testMsgPack() {
//        val byteBuffer = SmMsgPack.send(sm1)
//        debug{}
//        val done=SmMsgPack.recv(byteBuffer!!)
//        debug{}
//    }

    val sm1:ReifiedMessage = listOf("Alice" to "Bob", "Charley" to "Delta")  to "Random message Body here"

    fun testMsgPack() {
        val byteBuffer = send(sm1)
        debug()
        val done = recv(byteBuffer!!)
        debug()

    }
}

fun main() {
    SmMsgPackTest().testMsgPack()
}
esensar commented 3 years ago

I have created a separate issue for this (#57). Thanks for reporting!

It seems the issue is deserialization of nested structures or anything more complex. Fix will be released in 0.4.2 soon!