[SNMP4J] How to cancel a async request when the Response Event is from a PDU.Report?

Nelson Silva nelson.emanuel.silva at gmail.com
Wed Aug 2 12:29:03 CEST 2017


Hello,

I noticed a memory leak when i'm using async requests and i have a lot of
PDU.Reports.


>From the java doc i found that i need to cancel the request however the
source from the ResponseEvent is a ReportHandler and i don't have access to
the Snmp instance.

 // Always cancel async request when response has been received
*       // otherwise a memory leak is created! Not canceling a request
*       // immediately can be useful when sending a request to a broadcast
*       // address.
*       ((Snmp)event.getSource()).cancel(event.getRequest(), this);


I was expecting the source to be the Snmp instance.

On ReportProcessor we have this:

// return report
reqListener.onResponse(new ResponseEvent(this,
    e.getPeerAddress(),
    reqPDU,
    pdu,
    reqUserObject));


I believe it should be

reqListener.onResponse(new ResponseEvent(*Snmp.**this*,

    e.getPeerAddress(),
    reqPDU,
    pdu,
    reqUserObject));

regards,

This happens in every versions i have tested, 1.11.2 to 2.5.6

Nelson Silva


More information about the SNMP4J mailing list