Edward Lawrence wrote:Yes. I did get the following exception with the expected results.
Question: Why did it go ahead and produce the correct results after the exception?
It didn't.
The collar variable never got set to its new value because of the exception. Then you carried on after the exception as if everything was fine (even though it wasn't--the serialization/deserialization failed). Then you printed out some collar info, which still had its original value. It just so happens that collar having the original value looks exactly the same as collar after the results of a successful deserialization.
In other words, the particular incorrect results you had are indistinguishable from the desired results.
When an exception occurs, you need to either actually
handle it (meaning you retry or use some default value or do
something that can properly serve as "success" in that context), or else you don't catch it in the first place, or if you do, you log, wrap, and rethrow.
Merely catching an exception doesn't fix the problem.