V3 error indication counter not incremented

Hi. I was debugging some v3 traps and found an old SNMP4J question from 2012 that was useful. However, in that issue, the author also observed that the error indicator did not increment. He got, “ = 0”. That observation wasn’t really addressed in your response. Then I noticed the same zero in my errors. So I looked at my latest copy of SNMP4J (version 3.4.2) and in USM.java, around line 700 is the following switch statement. Notice that the event is a new CounterEvent every time, and it is never incremented. Is that perhaps a mistake, or intentional?


                    switch (status) {
                    case SnmpConstants.SNMPv3_USM_NOT_IN_TIME_WINDOW: {
                        logger.debug("RFC3414-3.2.7.a Not in time window; engineID='" +
                                securityEngineID +
                                "', engineBoots=" +
                                usmSecurityParameters.getAuthoritativeEngineBoots() +
                                ", engineTime=" +
                        CounterEvent **event** = new CounterEvent(this, SnmpConstants.usmStatsNotInTimeWindows);
                        statusInfo.setSecurityLevel(new Integer32(SecurityLevel.AUTH_NOPRIV));
                        statusInfo.setErrorIndication(new VariableBinding(**event**.getOid(), **event**.getCurrentValue()));
                        return status;
                    case SnmpConstants.SNMPv3_USM_UNKNOWN_ENGINEID: {
                        if (logger.isDebugEnabled()) {
                            logger.debug("RFC3414-3.2.7.b - Unknown engine ID: " + securityEngineID);
                        CounterEvent **event** = new CounterEvent(this, SnmpConstants.usmStatsUnknownEngineIDs);
                        if (SNMP4JSettings.getReportSecurityLevelStrategy() ==
                                SNMP4JSettings.ReportSecurityLevelStrategy.noAuthNoPrivIfNeeded) {
                            statusInfo.setSecurityLevel(new Integer32(SecurityLevel.NOAUTH_NOPRIV));
                        statusInfo.setErrorIndication(new VariableBinding(**event**.getOid(), **event**.getCurrentValue()));
                        return status;


When the counter is not incremented, you probably did not initialise the CounterSupport correctly.

The quoted code above is correct, the incrementation happens in the CounterListener (i.e. the CounterSupport instance):

 * Increment the supplied counter instance and return the current value
 * (after incrementation) in the event object if the event receiver is the
 * maintainer of the counter value.
 * @param event
 *   a {@code CounterEvent} instance.
void incrementCounter(CounterEvent event);

Ah, I see now… I should have followed the trail further. Sorry for taking your time.
Thank you,