bugMibble MIB Parser - Bugs: bug #36849, null pointer Exception

 
 

bug #36849: null pointer Exception

Submitted by:  Mark A. Mayberry-Billiot <mamb>
Submitted on:  Sun 15 Jul 2012 04:43:14 AM UTC  
 
Severity: 2 - NormalItem Group: None
Status: Wont FixPrivacy: Public
Assigned to: Per Cederberg <cederberg>Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sun 14 Oct 2012 03:34:02 PM UTC, comment #1:

The NPE is not in the Mibble library, but resides in your own code.

I agree that it is unexpected that getChild(0) returns null when getChildCount() has just returned one (1). But this is caused by the parent-child relationship being based on ObjectIdentifierValue instead of MibValueSymbol instances. As specified in the documentation:

"This is a convenience method for value symbols that have object identifier values."

That is, in some situations (tables) the OID tree contains hierarchy levels where no corresponding MibValueSymbol exists. In this case the MibValueSymbol.getChild() method returns null, but the corresponding ObjectIdentifierValue.getChild() does not.

The API docs could be clearer on this point. And the API could be easier to use as well (although that would be a breaking change for current users). I've added a separate bug report for that:
https://github.com/cederberg/mibble/issues/8

Per Cederberg <cederberg>
Project AdministratorIn charge of this item.
Sun 15 Jul 2012 04:43:14 AM UTC, original submission:

USing the following code snippet

numberOfChildren = ((MibValueSymbol)symbol).getChildCount();
if (numberOfChildren > 0) {
this.output.println(itemIndent + "<CHILDREN total=" + numberOfChildren + ">");
for (int i=0; i < numberOfChildren; i++) {
System.err.println("Number Of Children = " + numberOfChildren + " i = " + i);
writeSymbol(itemIndent + INDENT, ((MibValueSymbol)symbol).getChild(i));
}
this.output.println(itemIndent + "</CHILDREN>");
}

When first in the writeSymbol method I am getting the Exception when accessing the child passed in

Stack trace etc is below

Number Of Children = 9 i = 5
Number Of Children = 4 i = 0
Number Of Children = 4 i = 1
Number Of Children = 25 i = 0
Number Of Children = 1 i = 0
Exception in thread "main" java.lang.NullPointerException
at com.questcontrols.mib.io.XMLStream.writeSymbol(XMLStream.java:129)
at com.questcontrols.mib.io.XMLStream.writeSymbol(XMLStream.java:161)
at com.questcontrols.mib.io.XMLStream.writeSymbol(XMLStream.java:161)
at com.questcontrols.mib.io.XMLStream.writeSymbol(XMLStream.java:161)
at com.questcontrols.mib.io.XMLStream.writeSymbol(XMLStream.java:161)
at com.questcontrols.mib.io.XMLStream.writeSymbol(XMLStream.java:161)
at com.questcontrols.mib.io.XMLStream.writeMib(XMLStream.java:101)
at com.questcontrols.mib.parsers.MIBParser.main(MIBParser.java:173)

Mark A. Mayberry-Billiot <mamb>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #26202:  AbstractMIBStream.java added by mamb (2KiB - application/octet-stream)
file #26203:  MIBStream.java added by mamb (784B - application/octet-stream)
file #26204:  XMLStream.java added by mamb (13KiB - application/octet-stream)
file #26205:  MIBParser.java added by mamb (8KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by cederberg (Posted a comment)
  • -unavailable- added by mamb (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 14 Oct 2012 03:34:02 PM UTCcederbergSeverity5 - Major=>2 - Normal
      StatusNone=>Wont Fix
      Assigned toNone=>cederberg
      Open/ClosedOpen=>Closed
    Sun 15 Jul 2012 04:43:14 AM UTCmambAttached File-=>Added AbstractMIBStream.java, #26202
      Attached File-=>Added MIBStream.java, #26203
      Attached File-=>Added XMLStream.java, #26204
      Attached File-=>Added MIBParser.java, #26205

    Back to the top


    Powered by Savane 3.1-cleanup1