This content has been marked as final. Show 2 replies
The implementation states in its Javadoc:
@return 0 when equal, 1 if oid2 > oid1 and -1 if oid1>oid2
However, the implementation is wrong in its code:
int nd1 = countDots(oid1);
int nd2 = countDots(oid2);
res = nd1 - nd2;
if (res != 0) // different number of dots -> not equal
while it is true that a different number of dots means that OID(s) are not equal, it is most definitely NOT true that OID1 < OID2 if it is shorter. What matters is the VALUE of the FIRST non-matching OID component - e.g.:
22.214.171.124.1 < 1.3.6 even though 1.3.6 is the shorter OID
the correct implementation is to go component by component untill the first non-equal value is found. If one of the OID(s) is "exhausted" (i.e., it is a prefix of the other) then the shorter one comes first.
This mis-implementation causes a BUG in SNMP GETNEXT behavior as it returns WRONG OID(s). In this context, "compareOid" should be used to find the first OID that is GREATER than the requested one and NOT less than - as is currently the (wrong) implementation of the "getNextOid" method.