protected T deserialize(T object) throws IOException, ClassNotFoundException { byte[] buffer; final int byteArrayLength = 8 * 6; // 8 bytes (size of long/double) * 6 fields try (ByteArrayOutputStream baos = new ByteArrayOutputStream(byteArrayLength)) { try (ObjectOutputStream oos = new ObjectOutputStream(baos)) { externalizer.writeObject(oos, object); } buffer = baos.toByteArray(); } ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(buffer)); return externalizer.readObject(ois); }