StateVertix is not Serializable #53

alexnederlof opened this Issue Dec 4, 2012 · 0 comments


None yet

2 participants


Original author: (November 02, 2011 16:43:18)

What steps will reproduce the problem?

  1. Serialize a com.crawljax.core.state.StateVertix.

What is the expected output?
Serialization without errors/exceptions.

What do you see instead?
A NotSerializableException is thrown.

Please provide any additional information below.
A StateVertix contains a variable candidateActionsSearchLock, which is an Object to guard a critical section in the method searchForCandidateElements(), but an Object is not Serializable.

Possible solutions:

  1. Making the variable transient doesn't solve the problem, because during deserialization the variable would be set to the default value (null for objects), which leads to a NullPointerException when Java subsequently tries to acquire the lock for the critical section.

  2. Removing the variable and synchronizing the critical section on this instead of that variable probably works, but may lead to incorrect behavior if any other piece of code uses a StateVertix as a guard for a critical section.

  3. Changing the variable to a String and setting it to an empty String will work. It does not suffer from the problems of solution 1 and 2, only has a small memory footprint and doesn't require any extra lines of code.

Original issue:

@amesbah amesbah was assigned Dec 18, 2012
@amesbah amesbah closed this Dec 20, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment