Quests? serializing Hashmaps and Arraylist


currently i’m working on a basic mission / quest System and i ran into an old problem again.
A Part of a serlizable Object doesn’t get to the Client and i don’t understand why. I had this before and i thought it to be connected to using ArrayList and Hashmaps.

Im Using a HashMap<String,Mission>as list of Missions accepted by the player sending it to the client.

public class Mission {

public MissionConditionList conditions = new MissionConditionList();
public boolean solved = false;
public String uuid;
public String rewardtype;
public float rewardamount;


MissionConditionList is just an CopyOnWriteArrayList<MissionCondition> and Missioncondition currently is just a Hashmap<String, String>

in short, Missionlist -> Mission -> Conditionlist -> Condition
Every mission consists of things to do in a specific order.

currently all missions get to the client, the reward-information does as well but the missionconditionlist is empty.

I went back to ArrayList<MissionCondition> for MissionConditionList and had to get around some concurrentmodification-Exceptions.
Now the Missionconditionlist isn’t empty, but the content-Objects are null.

I’m doing a System.out.println() on server and clientside, so it has to be somewhere in between/serializing.

All classes are serializable.

Am i doing something wrong/stupid here? :slight_smile: - any other preferred way to do this - or whats wrong?


Presuming you are using SpiderMonkey, if things fail to serialize then there would be an error somewhere.

If you are not using SpiderMonkey then you will need to provide a lot more explanation, I guess.

As to: “had to get around some concurrentmodification-Exceptions.”

This is a sign that your threading is completely out of control. Networking is inherently multithreaded and you need to take care when you provide things to networking and when you receive things from networking to get them back into the proper context. Your life will be a continuous hell otherwise.

ok, thanks.

To spidermonkey: yes - as described and on other wiki-pages.

By now a bit more complex and sooner or later i have to cleanup me message-Subclasses - but besides that problem it’s working fine. Players can join, move around, switch levels/maps shoot each other, build Space-Stations and stuff like that.

Is there somekind of serilization-depth limit (hashmap -> arraylist -> hashmap->arraylist etc.) so i mind have a basic recursion-depth problem?

Even buying and selling equipment, which is very similar in code doesn’t have those problems - but i just see that i did some (presumably bad…) JSON-serialization there, before putting together the network-message, so never goes that deep.

With luck i can do some more testing today - but you don’t see any obvious problems with using arraylist and hashmap for that sort of thing?

To threading:

  • on clientside all messages are put in a LinkedList (via clientapp.enqueue) and the main-Thread does process them in update()

There is no depth limit… just a message size limit.

If your threading is working properly then you will not get concurrent modification exception. If you are then there is some data structure that is shared between threads when it shouldn’t be. For example, on the server are you copying the lists for inclusion in the messages or are you just plopping the reference in there that is shared with everything else?

Anyway, to find your serialization problem you will have to dig deeper or find the errors that are being output. If the messages are getting through (but only partially) then serialization is succeeding but some other part isn’t doing its job. Looked like you were using your own custom list classes instead of just using ArrayList, so I’d start there.