[SNMP4J] NPE when calling usm.removeAllUsers();

Matthieu Casanova chocolat.mou at gmail.com
Thu Aug 9 15:38:04 CEST 2007


Hi, I want to change dynamically the usm users in my agent. So I first
remove all users and add the new users again after that.
But when I call
usm.removeAllUsers();
I have this exception
java.lang.NullPointerException
        at org.snmp4j.agent.mo.snmp.UsmMIB.usmUserChange(UsmMIB.java:282)
        at org.snmp4j.security.USM.fireUsmUserChange(USM.java:1050)
        at org.snmp4j.security.USM.removeAllUsers(USM.java:943)


The reason is that in removeAllUsers() there is the following code
 fireUsmUserChange(new UsmUserEvent(this, null, UsmUserEvent.USER_REMOVED));

And in the UsmMIB line 282

OID index = createIndex(event.getUser().getEngineID(),
                                event.getUser().getUserName());

But event.getUser() is null so it fails.
I use the agent version 1.1.4

Matthieu



More information about the SNMP4J mailing list