@ Override public void writeJournalEntry ( CreatorJournalEntry journalEntry ) throws JournalException { if ( open ) { try { synchronized ( JournalWriter . SYNCHRONIZER ) { XMLEventWriter xmlWriter = currentJournal . getXmlWriter ( ) ; super . writeJournalEntry ( journalEntry , xmlWriter ) ; xmlWriter . flush ( ) ; currentJournal . closeIfAppropriate ( ) ; } } catch ( XMLStreamException e ) { throw new JournalException ( e ) ; } } }
We ve prepared for the entry so just write it but remember to synchronize on the file so we don t get an asynchronous close while we re writing . After writing the entry flush the file .