@ Override public void writeObject ( Object o ) { synchronized ( this ) { ArrayList < Object > prePending = objPrePendingCache . get ( o ) ; if ( prePending == null ) { boolean oldWritingObject = writingObject ; writingObject = true ; try { super . writeObject ( o ) ; } finally { writingObject = oldWritingObject ; } } else { flushPrePending . clear ( ) ; flushPrePending . addAll ( prePending ) ; } // root object if ( ! writingObject ) { boolean isNotCached = prePending == null ; // is not cached, add to cache if ( isNotCached && o != null ) { prePending = new ArrayList < Object > ( ) ; prePending . addAll ( flushPrePending ) ; objPrePendingCache . put ( o , prePending ) ; } // add to pending flushPending . addAll ( flushPrePending ) ; flushPendingStat . addAll ( flushPrePending ) ; flushPrePending . clear ( ) ; if ( isNotCached && flushPending . contains ( o ) ) { flushPendingStat . remove ( o ) ; } else { flushPending . add ( o ) ; } if ( needOwner ) { this . flushPending . remove ( owner ) ; this . flushPending . add ( 0 , owner ) ; } } } }
Records the object so that it can be written out later then calls super implementation .