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

Serializing Long is misleadingly using Int in transit #87

Open
Eragoneq opened this issue Apr 9, 2024 · 0 comments · May be fixed by #88
Open

Serializing Long is misleadingly using Int in transit #87

Eragoneq opened this issue Apr 9, 2024 · 0 comments · May be fixed by #88

Comments

@Eragoneq
Copy link

Eragoneq commented Apr 9, 2024

Another issue I found relates to the serialization of the Long values.

In the code seen below we can see an explicit cast to Int before putting the data in the buffer, thus the function downcasts to Int in serialization and upcasts back to Long when deserializing, causing confusion.

fun serializeLong(value: Long): ByteArray {
val buffer = ByteBuffer.allocate(SERIALIZED_LONG_SIZE)
buffer.putInt(value.toInt())
return buffer.array()
}

I suggest conforming to the naming and just using Long in transit and create a separate explicit Int serialization.

@Eragoneq Eragoneq linked a pull request Apr 9, 2024 that will close 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

Successfully merging a pull request may close this issue.

1 participant