Disabling removal of strong self reference

I am using treeUtils.getSubtree() API with the tree listener for the entire database query of our product.
For few tables, the error “request timeout” is thrown even after we receive the reply from SNMP agent.

SNMP4J logs removes the cache entry for all 3 retries - with the following logs:
“New entry does not match existing, although request ID is the same StateReference”

Is there a way to disable the removal of strong self reference?
Expected output: Return the cache entry without removal of cache - even if the new entry has arrived.

I think you did not fully understand the code in MPv3.Cache.addEntry. The removal of the “strong self reference” does not have any (direct) influence on the cache content. So this cannot be the reason why a response is not accepted.

However, if a response has a wrong requestID then it cannot be matched with the outstanding request and the request will timeout out. But that is required by the SNMP standard.

Thanks for your response.

As per my understanding, the request Id is same and two consecutive SNMP packets received on the same port for which the content is correct (with msgId difference and security model difference) and is a valid response - is resulting in a timeout because of cache entry removal.

Can we skip the cache entry removal if the request Id is same.

I assume that msgId and requestId are not the same. The debug msg from SNMP4J claims that the request ID is same. I see a difference in the msgId (2 consecutive numbers for 2 retries) as per the logs below

Logs for reference:

2022-05-30 10:17:59.914 Timer-7 DEBUG New entry does not match existing, although request ID is the same StateReference[msgID=23702,pduHandle=PduHandle[1616578728],securityEngineID=,securityModel=org.snmp4j.security.USM@38ae2846,securityName=FMS,securityLevel=1,contextEngineID=,contextName=FMS,retryMsgIDs=null] != StateReference[msgID=23701,pduHandle=PduHandle[1616578728],securityEngineID=,securityModel=org.snmp4j.security.USM@2b68cfaa,securityName=FMS,securityLevel=1,contextEngineID=,contextName=FMS,retryMsgIDs=null]

There is no “cache removal”. Thus, it cannot be disabled, because you cannot disable, what isn’t there.

BTW, why is the securityEngineID empty?