Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-2817

NPE during conversion of document to XML

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 1.7 M2
    • 1.4.1, 1.7 M1
    • {Unused} Core
    • None
    • NPE XWikiDocument XML

    Description

      An NPE may occurs during XML conversion at line 2269 of XWikiDocument.java in XWiki 1.4.1, which is currently line 2410 in latest SVN. Here is an excerpt:

                  // Add Objects (THEIR ORDER IS MOLDED IN STONE!)
                  for (Vector<BaseObject> objects : getxWikiObjects().values()) {
                      for (BaseObject obj : objects) {
                          if (obj != null) {
                              BaseClass objclass = null;
        here --->        if (obj.getName().equals(obj.getClassName())) {
                                  objclass = bclass;
                              } else {
                                  objclass = obj.getxWikiClass(context);
                              }
                              docel.add(obj.toXML(objclass));
                          }
                      }
                  }
              }
      

      I suggest that this line has to be replace by:

      if (getName().equals(obj.getClassName())) {
      

      This should not have any effect if proper naming of object are ensured (see XWIKI-2813), but currently the line says "if the name and classname of an object is the same, take the class of the document", my feeling is that it should say "if the name of the document is the classname of the object than take the class of the document", which is a clearer intend and reduce inter-dependancy

      Attachments

        Issue Links

          Activity

            People

              sdumitriu Sergiu Dumitriu
              softec Denis Gervalle
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: