My Java app stores a set of XML User datafiles at Quit time. It parses them back in at relaunch. A user reported a launch-time failure, and the cause was found to be one of these User datafiles was an empty file (zero text chars).
I'm using the JDOM (2.0.6) library, integrated with Java 1.8.0_291 JRE Win. The app does not create any new threads, i.e. it uses the default Swing-Java thread structure. The file write in question only takes place in the Quit sequence (triggered by User closing main app window).
Non-repeatable bug occurred once
This looks like a JDOM XML Outputter error of some kind. It occurred randomly running the app on a Windows 10 desktop computer. It is not repeatable (so far).
Here is the write code that sets up the file write:
public class XMLPersistantEditorWorkspace {
public static final int XML_DOC_VERSION = 1002;
public Document outputDoc = new Document();
private Document inputDoc = new Document();
public void writeXMLEditorStateUsingJDOM(FileOutputStream fileStream) throws IOException {
outputDoc.setRootElement(new Element("EditorWorkspace", XML_Utils.DFG2D_NAMESPACE));
Element editorStateXMLElement = generateAlgoEditingStackXMLElement();
outputDoc.getRootElement().addContent(editorStateXMLElement);
XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat());
//TEST ONLY: writes to console
//xmlOutputter.output(outputDoc, System.out);
xmlOutputter.output(outputDoc, fileStream);
}