Scenerio
We are using SNMP proxy in our agent and when we try to hit the target agent from our agent using USM, we get a NullPointerException
Sample Logs
09:11:48.070 [MasterAgent.0] DEBUG org.snmp4j.agent.request.SnmpRequest - Created subrequest 0 with scope org.snmp4j.agent.DefaultMOContextScope[context=,lowerBound=1.3.6.1.4.1.193.3.1.0,lowerIncluded=true,upperBound=1.3.6.1.4.1.193.3.1.0,upperIncluded=true] from 1.3.6.1.4.1.193.3.1.0 = Null
09:11:48.073 [MasterAgent.0] DEBUG org.snmp4j.agent.request.SnmpRequest - SnmpSubRequests initialized: [org.snmp4j.agent.request.SnmpRequest$SnmpSubRequest[scope=org.snmp4j.agent.DefaultMOContextScope[context=,lowerBound=1.3.6.1.4.1.193.3.1.0,lowerIncluded=true,upperBound=1.3.6.1.4.1.193.3.1.0,upperIncluded=true],vb=1.3.6.1.4.1.193.3.1.0 = Null,status=RequestStatus{processed=false, phaseComplete=false, errorStatus=0},query=null,index=0,targetMO=null]]
09:12:17.407 [MasterAgent.0] DEBUG org.snmp4j.agent.mo.snmp.VacmMIB - Access allowed for view ‘fullReadView’ by subtree 1.3 for OID 1.3.6.1.4.1.193.3.1.0
java.lang.NullPointerException
at org.snmp4j.agent.mo.snmp.SnmpTargetMIB$SnmpTargetAddrEntryRow.getTarget(SnmpTargetMIB.java:658)
at org.snmp4j.agent.mo.snmp.SnmpTargetMIB.getTarget(SnmpTargetMIB.java:236)
at org.snmp4j.agent.mo.snmp4j.MOSubtreeProxy.get(MOSubtreeProxy.java:137)
at org.snmp4j.agent.CommandProcessor$GetHandler.processPdu(CommandProcessor.java:1080)
at org.snmp4j.agent.CommandProcessor$GetHandler.processPdu(CommandProcessor.java:1047)
at org.snmp4j.agent.CommandProcessor.processRequest(CommandProcessor.java:428)
at org.snmp4j.agent.CommandProcessor.processRequest(CommandProcessor.java:384)
at org.snmp4j.agent.CommandProcessor.dispatchCommand(CommandProcessor.java:340)
09:15:18.381 [MasterAgent.0] WARN org.snmp4j.agent.CommandProcessor - java.lang.NullPointerException
at org.snmp4j.agent.CommandProcessor$Command.run(CommandProcessor.java:566)
at org.snmp4j.util.ThreadPool$TaskManager.run(ThreadPool.java:312)
java.lang.Exception: Error ‘General variable binding error’ generated at: 1.3.6.1.4.1.193.3.1.0 = Null
at org.snmp4j.agent.request.SnmpRequest$SnmpSubRequest.requestStatusChanged(SnmpRequest.java:627)
at org.snmp4j.agent.request.RequestStatus.fireRequestStatusChanged(RequestStatus.java:89)
at org.snmp4j.agent.request.RequestStatus.setErrorStatus(RequestStatus.java:52)
at org.snmp4j.agent.CommandProcessor$GetHandler.processPdu(CommandProcessor.java:1093)
at org.snmp4j.agent.CommandProcessor$GetHandler.processPdu(CommandProcessor.java:1047)
at org.snmp4j.agent.CommandProcessor.processRequest(CommandProcessor.java:428)
at org.snmp4j.agent.CommandProcessor.processRequest(CommandProcessor.java:384)
at org.snmp4j.agent.CommandProcessor.dispatchCommand(CommandProcessor.java:340)
at org.snmp4j.agent.CommandProcessor$Command.run(CommandProcessor.java:566)
at org.snmp4j.util.ThreadPool$TaskManager.run(ThreadPool.java:312)
09:15:18.386 [MasterAgent.0] DEBUG org.snmp4j.transport.DefaultUdpTransportMapping - Sending message to 127.0.0.1/34595 with length 45: 30:2b:02:01:01:04:06:45:53:41:2d:50:45:a2:1e:02:04:36:fe:c6:7c:02:01:05:02:01:01:30:10:30:0e:06:0a:2b:06:01:04:01:81:41:03:01:00:05:00
09:15:18.387 [DefaultUDPTransportMapping_0.0.0.0/0] DEBUG org.snmp4j.transport.DefaultUdpTransportMapping - Received message from /127.0.0.1/1161 with length 45: 30:2b:02:01:01:04:06:45:53:41:2d:50:45:a2:1e:02:04:36:fe:c6:7c:02:01:05:02:01:01:30:10:30:0e:06:0a:2b:06:01:04:01:81:41:03:01:00:05:00
09:15:18.387 [DefaultUDPTransportMapping_0.0.0.0/0] DEBUG org.snmp4j.Snmp - Looking up pending request with handle PduHandle[922666620]
09:15:18.387 [DefaultUDPTransportMapping_0.0.0.0/0] WARN org.snmp4j.Snmp - Received response that cannot be matched to any outstanding request, address=127.0.0.1/1161, requestID=922666620
Suspect
We get this NullPointerException when we upgraded the snmp4j-agent version from “2.7.4” to “2.7.6”. We guess this is some regression in version “2.7.5”
I suspect the highlighted line of code could be triggering the exception
if (paramsRow.getValue(idxSnmpTargetParamsMPModel).toInt() == MPv3.ID) {
SnmpTlsTmMib myTlsTmMib = tlsTmMib;
if (myTlsTmMib != null) {
t = getTlsTmTarget(addr, secName, getIndex(), paramsIndex, myTlsTmMib);
t.setSecurityLevel(paramsRow.getValue(idxSnmpTargetParamsSecurityLevel).toInt());
}
if (t == null) {
if (contextEngineID != null) {
t = new UserTarget(addr, secName, contextEngineID.getValue(),
paramsRow.getValue(idxSnmpTargetParamsSecurityLevel).toInt());
}
else {
return null;
}
}
}
We are trying to report this issue in JIRA but the link is down lately
Any help is greatly appreciated.