@ Override public Invoke duplicate ( ) throws IOException , ClassNotFoundException { Invoke result = new Invoke ( ) ; ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; ObjectOutputStream oos = new ObjectOutputStream ( baos ) ; writeExternal ( oos ) ; oos . close ( ) ; byte [ ] buf = baos . toByteArray ( ) ; baos . close ( ) ; ByteArrayInputStream bais = new ByteArrayInputStream ( buf ) ; ObjectInputStream ois = new ObjectInputStream ( bais ) ; result . readExternal ( ois ) ; ois . close ( ) ; bais . close ( ) ; return result ; }
Duplicate this Invoke message to future injection . Serialize to memory and deserialize safe way .