Today I have came across strange behavior in java serialization and deserialization("strange" because I don't understand)
I was serializing and deserializing an object from a linux shared directory.
While serializing everything worked without any problem, but when I tried to deserialize the same file it throws
java. io. EOFException
. Also deserializing was only failing for this newly created file and was working for all other old files in that directory.
So I searched across internet and found one thread which said Low disk space can also be cause of this error.
So I cleaned up some temp files and voila it worked. I do not understand how low disk space can only affect deserialization and not serialization?
I am using apache commons SerializationUtils
class. Below is the code for serialization and deserialization
SerializationUtils. serialize(myObject, new FileOutputStream(new File(sharePath+FILEName) ;
MyObject object=SerializationUtils. deserialize( new FileInputStream(new File(sharePath+FILEName);
It would be really helpful if someone can explain this behavior. I suspect its a bug in SerializationUtils maybe gobbling up IOException.
Thanks