0

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);
    }
Abra
  • 19,142
  • 7
  • 29
  • 41
pbierre
  • 276
  • 1
  • 8

1 Answers1

0

This turned out to be related to the fact that:

In rapid-prototyping this app, the Serializable interface was utilized to store objects to disk file.

When a decision was made to promote the prototype to a product, and to redesign file storage using XML, I didn't know that you have to purge your classes of implementing the Serializable interface first. Doing so solved the problem.

pbierre
  • 276
  • 1
  • 8