[SNMP4J] Agent bug
Frank Fock
fock at agentpp.com
Thu May 5 02:54:56 CEST 2005
Hi William,
The correct implementation of the MOScalar.isVolatileByDefault method
should have read as follows:
private static boolean isVolatileByDefault(Variable value) {
if (value == null) {
return true;
}
switch (value.getSyntax()) {
case SMIConstants.SYNTAX_COUNTER32:
case SMIConstants.SYNTAX_COUNTER64: {
return true;
}
default:
return false;
}
}
This fix will be of course in the next alpha.
Best regards,
Frank
Simakis, William wrote:
>Hi,
>
>I am trying to implement a simple agent and I am trying to familiarize myself with the API etc. I am getting the following exception when I run the TestAgent example.
>
>Exception in thread "main" java.lang.NullPointerException
> at org.snmp4j.agent.mo.MOScalar.isVolatileByDefault(MOScalar.java:54)
> at org.snmp4j.agent.mo.MOScalar.<init>(MOScalar.java:50)
> at org.snmp4j.agent.mo.snmp.SnmpFrameworkMIB$1.<init>(SnmpFrameworkMIB.java:56)
> at org.snmp4j.agent.mo.snmp.SnmpFrameworkMIB.createMOs(SnmpFrameworkMIB.java:56)
> at org.snmp4j.agent.mo.snmp.SnmpFrameworkMIB.<init>(SnmpFrameworkMIB.java:52)
> at org.snmp4j.agent.BaseAgent.init(BaseAgent.java:80)
> at org.snmp4j.agent.test.TestAgent.main(TestAgent.java:270)
>
>Here is the problem in the code:
>
>1) In SnmpFrameworkMIB.createMOs, a MOScalar is created and passed null to the constructor for the value parameter.
>2) The MOScalar constructor calls isVolatileByDefault with the null reference
>3) isVolatileByDefault tries to call value.getSyntax without checking if the reference is null.
>
>from the name I would guess it should return false if the value is null but I am not that familiar with what it is used for.
>
>Bill
>_______________________________________________
>SNMP4J mailing list
>SNMP4J at agentpp.org
>http://lists.agentpp.org/mailman/listinfo/snmp4j
>
>
>
More information about the SNMP4J
mailing list