Skip to content

MapReference resolver throws java.lang.IndexOutOfBoundsException when trying to round trip to and from file #691

@amf08006

Description

@amf08006

Describe the bug
Serializing a simple map to a byte array, persisting to a file, and then reading bytearray back from file fails with IndexOutOfBoundsException

To Reproduce
Steps to reproduce the behavior:
This is an example of a test that reproduces the problem
`
val mapToSerialize = Map("1" -> "Bananna", "2" -> "Apple", "3" -> "Cheese")
val path = Paths.get("/c/temp/testFile.bytes")

val serializedBytes = Base64.getEncoder.encodeToString(ScalaKryoInstantiator.defaultPool.toBytesWithClass(mapToSerialize))
if(!Files.exists(path.getParent)) Files.createDirectories(path.getParent)
val writer = new BufferedWriter(new FileWriter(path.toFile))
writer.write(serializedBytes )
writer.close()

val byteArray = FileUtils.readFileToByteArray(path.toFile)
val readFromFile = ScalaKryoInstantiator.defaultPool.fromBytes(byteArray).asInstanceOf[Map[String, String]]
`

Expected behavior
I would expect to be able to write the encoded byte array to file, read it back, and deserialize properly

Screenshots
N/A

Environment
Version 0.1.0
Scala 2.11

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions