Skip to content
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

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

Open
amf08006 opened this issue Aug 19, 2022 · 1 comment

Comments

@amf08006
Copy link

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.

@harmeet24
Copy link

any update on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants