Uploaded image for project: 'ODF Toolkit'
  1. ODF Toolkit
  2. ODFTOOLKIT-195

Exception when remove Table in odt

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • odfdom-0.8.6
    • None
    • java
    • None
    • Operating System: Windows
      Platform: PC
    • 336

    Description

      One of ODFDOM user reported a NPE exception when removing a table element. The exception was:

      testIndexTable(com.ibm.symphony.conversion.service.junit.cases.TestConversionServiceWithTargetFolder)java.lang.NullPointerException
      at org.odftoolkit.odfdom.OdfElement.equals(OdfElement.java:408)
      at java.util.ArrayList.indexOf(ArrayList.java:461)
      at java.util.ArrayList.remove(ArrayList.java:570)
      at org.odftoolkit.odfdom.dom.element.OdfStyleBase.removeStyleUser(OdfStyleBase.java:159)
      at org.odftoolkit.odfdom.dom.element.OdfStylableElement.onRemoveNode(OdfStylableElement.java:445)
      at org.odftoolkit.odfdom.OdfElement.onRemoveNode(OdfElement.java:476)
      at org.odftoolkit.odfdom.OdfElement.onRemoveNode(OdfElement.java:471)
      at org.odftoolkit.odfdom.OdfElement.removeChild(OdfElement.java:506)
      at ......

      I looked into the code. The NPE happens in:

      Public boolean equals(Object obj) {
      ......
      if (n1.getLocalName().equals(n2.getLocalName())
      && n1.getNamespaceURI().equals(n2.getNamespaceURI()))

      { break; }

      ......
      }

      The problem is caused by an XML attribute added by user without a namespace, such as "key=123".

      I think ODFDOM should support this case, to avoid NPE.
      Patch will be uploaded latter.

      Daisy

      Attachments

        Activity

          People

            issues@odfdom.odftoolkit.org issues
            daisy@odftoolkit.org Ying Chun Guo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: