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

Queue Serializer not working properly. #4

Open
RubySunset opened this issue Jan 27, 2019 · 2 comments
Open

Queue Serializer not working properly. #4

RubySunset opened this issue Jan 27, 2019 · 2 comments

Comments

@RubySunset
Copy link
Contributor

Attempting to serialize and deserialize a queue of arrays, then calling addFirst or addLast on the Queue throws an array index out of bounds exception, refering to the field 'head' in Queue. This is definitely a problem with serialization since re-initialising the queue solves the problem. This error occurs in both version 1.1.0 and 1.1.1.

Interestingly, calling addFirst throws an ArrayIndexOutOfBoundsException: -1, whereas calling addLast throws an ArrayIndexOutOfBoundsException: 0.

@cypherdare
Copy link
Contributor

Sorry for the slow response. I haven't had a chance to look into this one yet. If you'd like to submit a testNestedCollection() to the collections tests that illustrates the failure, I'd certainly appreciate it.

Unfortunately, I accidentally placed the PC containing my only copy of my keystore in a storage unit buried with stuff I don't intend to retrieve for a couple years. Too painful to dig it out, so I'm debating whether I should create a new repository to get fixes out sooner. You're the first I know of who is using gdxtokryo besides myself.

@RubySunset
Copy link
Contributor Author

RubySunset commented Feb 18, 2019

After some testing I've found that 1) this issue affects all queues, not just nested ones and 2) it only affects empty queues.

I've written a test and submitted a pull request. I didn't use your equals method because on the surface, the original and deserialised queues look functionally identical, you only start seeing problems when you try to add to the deserialised one. So the test just throws an exception when you run it.

Also, I think there might be other people who use gdxtokryo. In fact, I found this repo when someone suggested it to me on the libGDX discord when I asked if anyone had written serialisers for common gdx classes.

EDIT: Just remembered that I found a temporary fix a while ago, if you use ensureCapacity on the deserialised queue, it works fine.

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