Hi Franck,

I'll have to look into that. It seems to me that the request pdu might also be 
null but I might be wrong.

I've based my code on the sample in snmp javadoc : 

     ResponseListener listener = new ResponseListener() {
         public void onResponse(ResponseEvent event) {
           // 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);
           System.out.println("Received response PDU is: "+event.getResponse());
         }
       };

When running this, I get a null pointer (when the underlying code call 
gethashcode()) because event.getRequest() returns null.

regards,

Pierre Rust


________________________________________
De : Frank Fock [f...@agentpp.com]
Date d'envoi : lundi 21 octobre 2013 16:05
À : RUST Pierre IMT/OLPS; snmp4j@agentpp.org
Objet : Re: RE : [SNMP4J] NPE in pduHandleAssigned

Hi Pierre,

Synchronous requests do not have to be canceled.
Asynchronous requests have to be canceled with the *request* PDU.
Thus, it is not relevant if the response PDU is null or not. Simply use
the request PDU.

Best regards,
Frank


Am 21.10.2013 11:23, schrieb pierre.r...@orange.com:
> Hi,
>
> I have another question about this issue.
>
> When cancelling a request (either when closing or on an asynchronous request, 
> at the end of onResponse(ResponseEvent event)  ) the PDU might be null if the 
> request timed out.
> I've read in the javadoc of Snmp that an asynchronous request must always be 
> cancelled otherwise a memory leak is created. How can you cancel the request 
> when the pdu is null ? Or maybe you don't need to cancel it if the pdu is 
> null ?
>
> thanks,
>
> Pierre Rust
>
> ________________________________________
> De : snmp4j-boun...@agentpp.org [snmp4j-boun...@agentpp.org] de la part de 
> Frank Fock [f...@agentpp.com]
> Date d'envoi : vendredi 11 octobre 2013 12:49
> À : snmp4j@agentpp.org
> Objet : Re: [SNMP4J] NPE in pduHandleAssigned
>
> Hi Pierre,
>
> You can avoid this exception if you cancel all pending requests before
> you close
> the Snmp session.
>
> I agree, that the Snmp.close() should do this for you. I will provide a fix
> for it in version 2.2.3.
>
> Best regards,
> Frank
>
> Am 11.10.2013 10:45, schrieb pierre.r...@orange.com:
>> Hi,
>>
>> I'm using SNMP4J and I'm sometime getting an NPE in pduHandleAssigned :
>>
>> java.lang.NullPointerException
>> at org.snmp4j.Snmp$PendingRequest.pduHandleAssigned(Snmp.java:1624)
>> at org.snmp4j.Snmp$PendingRequest.pduHandleAssigned(Snmp.java:1485)
>> at org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:495)
>> at org.snmp4j.Snmp.sendMessage(Snmp.java:1005)
>> at org.snmp4j.Snmp$PendingRequest.run(Snmp.java:1666)
>> at java.util.Timer$TimerImpl.run(Timer.java:284)
>>
>> Given that the line 1624 is :  "timer.schedule(this, delay);" , I assume the 
>> timer is null.
>>
>> It might be that this happens when closing SNMP4J with an ongoing 
>> PendingRequest  (in close(),  line 509, timer is set to null) but I'm 
>> unfortunately not able to confirm this assumption : the problem only happens 
>> "on the field" and I never reproduce it in debug.
>>
>> In can upgrade to 2.2.2, but I don't see any relevant difference in the 
>> (potentially offending) code.
>>
>> Do you have any idea of what I could do investigate this issue ?
>>
>>
>> thanks a lot for the good work,
>>
>> Pierre Rust
>>
>>
>>
>>
>> _________________________________________________________________________________________________________________________
>>
>> Ce message et ses pieces jointes peuvent contenir des informations 
>> confidentielles ou privilegiees et ne doivent donc
>> pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu 
>> ce message par erreur, veuillez le signaler
>> a l'expediteur et le detruire ainsi que les pieces jointes. Les messages 
>> electroniques etant susceptibles d'alteration,
>> Orange decline toute responsabilite si ce message a ete altere, deforme ou 
>> falsifie. Merci.
>>
>> This message and its attachments may contain confidential or privileged 
>> information that may be protected by law;
>> they should not be distributed, used or copied without authorisation.
>> If you have received this email in error, please notify the sender and 
>> delete this message and its attachments.
>> As emails may be altered, Orange is not liable for messages that have been 
>> modified, changed or falsified.
>> Thank you.
>>
>> _______________________________________________
>> SNMP4J mailing list
>> SNMP4J@agentpp.org
>> http://lists.agentpp.org/mailman/listinfo/snmp4j
> --
> ---
> AGENT++
> Maximilian-Kolbe-Str. 10
> 73257 Koengen, Germany
> https://agentpp.com
> Phone: +49 7024 8688230
> Fax:   +49 7024 8688231
>
> _______________________________________________
> SNMP4J mailing list
> SNMP4J@agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j
>
> _________________________________________________________________________________________________________________________
>
> Ce message et ses pieces jointes peuvent contenir des informations 
> confidentielles ou privilegiees et ne doivent donc
> pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu 
> ce message par erreur, veuillez le signaler
> a l'expediteur et le detruire ainsi que les pieces jointes. Les messages 
> electroniques etant susceptibles d'alteration,
> Orange decline toute responsabilite si ce message a ete altere, deforme ou 
> falsifie. Merci.
>
> This message and its attachments may contain confidential or privileged 
> information that may be protected by law;
> they should not be distributed, used or copied without authorisation.
> If you have received this email in error, please notify the sender and delete 
> this message and its attachments.
> As emails may be altered, Orange is not liable for messages that have been 
> modified, changed or falsified.
> Thank you.
>

--
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax:   +49 7024 8688231


_________________________________________________________________________________________________________________________

Ce message et ses pieces jointes peuvent contenir des informations 
confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce 
message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages 
electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou 
falsifie. Merci.

This message and its attachments may contain confidential or privileged 
information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete 
this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been 
modified, changed or falsified.
Thank you.

_______________________________________________
SNMP4J mailing list
SNMP4J@agentpp.org
http://lists.agentpp.org/mailman/listinfo/snmp4j

Reply via email to