ObjectInputStream stream = null;
try {
stream = new ThreadObjectInputStream(new ByteArrayInputStream(bytes));
return stream.readObject();
} catch (ClassNotFoundException | IOException e) {
throw new SerializationException(e.getMessage());
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {