[SNMP4J] TableUtils.getTable() null pointer exception

Frank Fock fock at agentpp.com
Wed Apr 12 18:25:08 CEST 2017


Hi Stuart,

What SNMP4J version are you using?

Best regards,
Frank


> On 12. Apr 2017, at 18:19, Stuart Johnston <sgjohnston at gmail.com> wrote:
> 
> Using TableUtils.getTable() can cause a null pointer exception when used with SNMPv3, when the PDU is created. DefaultPDUFactory.createPDU() is called, which calls 
> applyContextInfoToScopedPDU() to set the engine ID. If the engine ID has not previously been set in the DefaultPDUFactory, then an NPE will be thrown. In fact, we really don’t want to have to specify the engine ID in the PDU factory, since snmp4j will automatically discover it and apply it if it isn’t set. The solution is to create a DefaultPDUFactory with an empty (rather than null) engine ID. In this cause, everything works as expected.
> 
> The immediate workaround is to call new DefaultPDUFactory(PDU.GET) rather than new DefaultPDUFactory(). new DefaultPDUFactory(PDU.GET) will create an empty, rather than null engine ID. I think the correct, long term fix is to change the constructor to:
> 
> /**
>  * Creates a PDU factory for the {@link PDU#GET} PDU type.
>  */
> public DefaultPDUFactory() {
>     this(PDU.GET);
> }
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> https://oosnmp.net/mailman/listinfo/snmp4j




More information about the SNMP4J mailing list