[SNMP4J] SNMP4J Problem using OID.nextPeer()

Zinger, Anthony J anthony.j.zinger at lmco.com
Wed Apr 19 14:14:35 CEST 2006


Hello,

 

  I have SNMP4J version 1.7 installed on a Windows PC running Microsoft
Windows XP Version 2002 Service Pack 2.

 

  A sample of my code using the OID.nextPeer() method:

 

             OID testOID = new OID(new int[] { 1,3,6,1,4,1,100,1,2,3,0
});

 

             PDU request = new ScopedPDU();

request.setType(PDU.GET);

             request.add(new VariableBinding(testOID));

             ResponseEvent responseEvent = sendSNMPMessage(snmp,
request, target);

                          :

                          :

             testOID = testOID.nextPeer();

 

  I was trying to get the next OID value for an entry in my MIB using
the OID.nextPeer() method and I got the:

 Exception in thread "main" java.lang.StackOverflowError

      at org.snmp4j.smi.OID.nextPeer(OID.java:627)

      at org.snmp4j.smi.OID.nextPeer(OID.java:628)

      at org.snmp4j.smi.OID.nextPeer(OID.java:628)

      at org.snmp4j.smi.OID.nextPeer(OID.java:628)

      at org.snmp4j.smi.OID.nextPeer(OID.java:628)

      at org.snmp4j.smi.OID.nextPeer(OID.java:628)

      at org.snmp4j.smi.OID.nextPeer(OID.java:628)

      at org.snmp4j.smi.OID.nextPeer(OID.java:628)

at org.snmp4j.smi.OID.nextPeer(OID.java:628)

 

  After adding some debug messages to OID.nextPeer(), I determined that
the check for last() < MAX_SUBID_VALUE in the  IF statement was always
returning false:

      if ((next.size() > 0) && (last() < MAX_SUBID_VALUE)) {

 

  The MAX_SUBID_VALUE is defined as:

      public static final int MAX_SUBID_VALUE = 0xFFFFFFFF;

 

  Executing this code on my PC interprets the MAX_SUBID_VALUE as -1 and
therefore fails.

  To resolve this problem, I defined MAX_SUBID_VALUE to be 0x7FFFFFFF,
and this problem went away.

 

  So a potential fix for this problem would be to define the
MAX_SUBID_VALUE as an "UNSIGNED" int or have a value of 0x7FFFFFFF.

 

  If this is not the correct solution to this problem, could you please
supply me with an explanation as to what it should be or what I am doing
wrong.

 

  Thanks for your help in resolving this problem.

 

Anthony J. Zinger




More information about the SNMP4J mailing list