BUG in DomOutputCapsule writeSavableArrayList()

Simple bug in DomOutputCapsule writeSavableArrayList():



if the array is inited but contains nulls, you get a wrong XML (that indeed will create exceptions when decoded. Try with a BezierCurve()):



<?xml  version='1.0' encoding='UTF-8'?>

<com.jme.curve.BezierCurve name='BezierCurve'>

    <texBuf size='1'/>

</com.jme.curve.BezierCurve>



instead of



<?xml  version='1.0' encoding='UTF-8'?>

<com.jme.curve.BezierCurve name='BezierCurve'>

    <texBuf size='1'>

        <null/>

    </texBuf>

</com.jme.curve.BezierCurve>





Committers please fix as following:





    public void writeSavableArrayList(ArrayList array, String name, ArrayList defVal) throws IOException {
        if (array == null) {
            return;
        }
        if (array.equals(defVal)) {
            return;
        }
        Element old = currentElement;
        Element el = appendElement(name);
        currentElement = el;
        el.setAttribute(XMLExporter.ATTRIBUTE_SIZE, String.valueOf(array.size()));
        for (Object o : array) {
           if(o == null) {
                Element before = currentElement;
                appendElement("null");
                currentElement = before;
           }
           else if (o instanceof Savable) {
                Savable s = (Savable) o;
                write(s, s.getClassTag().getName(), null);
            } else {
                throw new ClassCastException("Not a Savable instance: " + o);
            }
        }
        currentElement = old;
    }



Cheers,

Mik

Here's the patch



Index: DOMOutputCapsule.java
===================================================================
--- DOMOutputCapsule.java   (revision 4799)
+++ DOMOutputCapsule.java   (working copy)
@@ -547,7 +547,9 @@
         el.setAttribute(XMLExporter.ATTRIBUTE_SIZE, String.valueOf(array.size()));
         for (Object o : array) {
            if(o == null) {
-              continue;
+                Element before = currentElement;
+                appendElement("null");
+                currentElement = before;
            }
            else if (o instanceof Savable) {
                 Savable s = (Savable) o;