Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1383

DOMBuilder class raises NPE if value is null

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.0-JSR-5
    • 1.1-beta-1
    • XML Processing
    • None

    Description

      DomBuilder.createNode() raises NPE exception if attribute value is null.
      line 182 element.setAttribute(attrName, value.toString());

      It's very inconveniently check every attribute for null value in script.
      Exampe:
      def element = xml.DOCUMENT (
      ASSET: assetId == null ? "" : asset,
      EXCHANGE_RATE: exchangeRate == null ? "" : exchangeRate,
      ...
      At the same time SaxBuilder do this check
      line 109 :
      String valueText = (value != null) ? value.toString() : "";
      I think DomBuilder.parseNode() must be done the same way. Null value must be interpreted like empty string.

      Attachments

        Activity

          People

            paulk Paul King
            alexey_potapov Alexey Potapov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: