Jettison
  1. Jettison
  2. JETTISON-45

Null Pointer Exception getting text length

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0-RC2, 1.0
    • Fix Version/s: 1.3.3
    • Labels:
      None
    • Environment:
      windows xp pro sp2
    • Testcase included:
      yes
    • Number of attachments :
      0

      Description

      There needs to be a guard for NPE.

      getTextLength() below causes an NPE. I have been through this with a debugger and reader is NOT null. This should return 0 like getTextOffset() does.

      AbstractXMLStreamReader reader = null;
      try {
      reader = new MappedXMLStreamReader(jsonObject);
      System.out.println("Version: " + reader.getVersion());
      System.out.println("Count: " + reader.getAttributeCount());
      while (reader.hasNext())

      { System.out.println("************************"); System.out.println("Element Text: " + reader.getElementText()); System.out.println("Local Name: " + reader.getLocalName()); System.out.println("Text Start Offset: " + reader.getTextStart()); System.out.println("Text Length: " + reader.getTextLength()); System.out.println("Text: " + reader.getText()); System.out.println("PIData: " + reader.getPIData()); System.out.println("PITarget: " + reader.getPITarget()); }

      } finally

      { reader.close(); }

      As String: {"device-types":{"device-type":[

      {"@type-key":"WiFiStation","$":"WiFi Device"}

      ,

      {"@type-key":"MultispectralTag","$":"Multispectral Tag"}

      ,

      {"@type-key":"WiFiTag","$":"WiFi Tag"}

      ,

      {"@type-key":"V2PanGoTag","$":"PanGo V2 Tag"}

      ,

      {"@type-key":"PassiveTag","$":"Passive Tag"}

      ,

      {"@type-key":"VERSUS_BADGE","$":"Versus Badge"}

      ,

      {"@type-key":"V3PanGoTag","$":"PanGo V3 Tag"}

      ,

      {"@type-key":"InnerWirelessTag","$":"InnerWireless Tag"}

      ]}}
      Version: null
      Count: 0
      ************************
      Element Text: null
      Local Name: device-types
      Text Start Offset: 0

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Sergey Beryozkin
            Reporter:
            David Tkaczyk
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: