XMLEncoder behavior

From: Cris Daniluk (cris.danilu..mail.com)
Date: Wed Dec 14 2005 - 20:36:26 EST

  • Next message: Andrus Adamchik: "Re: XMLEncoder behavior"

    In working on the GenericDataService, I noticed (and had to work
    around) some very unintuitive behavior in the XMLEncoder. When a
    single result is returned, the rootTag is not included in the document
    tree. The offending code is:

            // if synthetic root has a single child, use child as a root
            Node root = document.getDocumentElement();
            if (root.getChildNodes().getLength() == 1) {
                root = root.getFirstChild();
            }

    I can't figure out why you would want this, but if you're encoding a
    list, the behavior will be different if the list happens to have only
    one element in it, making a very difficult to debug problem. I think
    we should overload the encode method so that if a collection is
    passed, instead of an Object, this behavior is disabled.

    Would be happy to submit a JIRA and/or patch if necessary.

    Cris



    This archive was generated by hypermail 2.0.0 : Wed Dec 14 2005 - 20:36:28 EST