JCR-2323: Fix cases where an IOException is thrown while serializing the data