Re: [SNMP4J] RuntimeException on shutdown

2018-11-16 Thread forum
Frank, 

Tested and confirmed: v2.7.0 has the issue resolved. 

Thanks, 
Mark 

On 2018-11-15 15:21, Frank Fock wrote: 

> Hi Mark,
> 
> The following snapshot 2.7.0 release should provide a fix for this
> issue:
> https://snmp.app/dist/snapshot/org/snmp4j/snmp4j/2.7.0-SNAPSHOT/snmp4j-2.7.0-20181115.204944-10.jar
> 
> Best regards,
> Frank
> 
>> On 15. Nov 2018, at 18:08, fo...@friendlysnmp.org wrote:
>> 
>> I implemented notification 'appShutdown' as follows:
>> 1. NotificationOriginatorImpl -> notify() with 'appShutdown'
>> notification.
>> 2. Snmp -> close() to release all resources.
>> 3. Close application.
>> 
>> The result is exception (line numbers are for SNMP4J v2.6.2):
>> java.lang.RuntimeException: java.net.SocketException: socket closed
>> at
> org.snmp4j.transport.DefaultUdpTransportMapping$ListenThread.run(DefaultUdpTransportMapping.java:455)
>  
> 
>> at java.lang.Thread.run(Thread.java:748)
>> Caused by: java.net.SocketException: socket closed
>> at
> java.net.DualStackPlainDatagramSocketImpl.socketReceiveOrPeekData(Native 
> 
>> Method)
>> at
> java.net.DualStackPlainDatagramSocketImpl.receive0(DualStackPlainDatagramSocketImpl.java:124)
>  
> 
>> at
> java.net.AbstractPlainDatagramSocketImpl.receive(AbstractPlainDatagramSocketImpl.java:143)
>  
> 
>> at java.net.DatagramSocket.receive(DatagramSocket.java:812)
>> at
> org.snmp4j.transport.DefaultUdpTransportMapping$ListenThread.run(DefaultUdpTransportMapping.java:397)
>  
> 
>> at java.lang.Thread.run(Thread.java:748)
>> 
>> I think the reason for the exception thrown is the 'appShutdown'
>> notification confirmation packet comes *after* all resources are
>> closed. The packet is processed in
>> DefaultUdpTransportMapping.ListenThread.run() line-397
>> socketCopy.receive(packet).
>> This method throws SocketException because the resources are closed,
>> and the catch at line-455 re-throws RuntimeException.
>> As the result DefaultUdpTransportMapping.ListenThread is not stopped
>> and application fails to exit.
>> 
>> What would you suggest to fix the exception in this scenario?
>> Maybe additional boolean flag in TransportMapping could be added to
>> signal WorkerTask not to process any packets if TransportMapping is
>> closed?
>> 
>> Thanks,
>> Mark
>> 
>> ___
>> SNMP4J mailing list
>> SNMP4J@agentpp.org
>> https://oosnmp.net/mailman/listinfo/snmp4j
___
SNMP4J mailing list
SNMP4J@agentpp.org
https://oosnmp.net/mailman/listinfo/snmp4j


Re: [SNMP4J] RuntimeException on shutdown

2018-11-15 Thread Frank Fock
Hi Mark,

The following snapshot 2.7.0 release should provide a fix for this issue:
https://snmp.app/dist/snapshot/org/snmp4j/snmp4j/2.7.0-SNAPSHOT/snmp4j-2.7.0-20181115.204944-10.jar
 


Best regards,
Frank

> On 15. Nov 2018, at 18:08, fo...@friendlysnmp.org wrote:
> 
> I implemented notification 'appShutdown' as follows:
> 1. NotificationOriginatorImpl -> notify() with 'appShutdown' notification.
> 2. Snmp -> close() to release all resources.
> 3. Close application.
> 
> The result is exception (line numbers are for SNMP4J v2.6.2):
> java.lang.RuntimeException: java.net.SocketException: socket closed
>  at 
> org.snmp4j.transport.DefaultUdpTransportMapping$ListenThread.run(DefaultUdpTransportMapping.java:455)
>  at java.lang.Thread.run(Thread.java:748)
> Caused by: java.net.SocketException: socket closed
>  at java.net.DualStackPlainDatagramSocketImpl.socketReceiveOrPeekData(Native 
> Method)
>  at 
> java.net.DualStackPlainDatagramSocketImpl.receive0(DualStackPlainDatagramSocketImpl.java:124)
>  at 
> java.net.AbstractPlainDatagramSocketImpl.receive(AbstractPlainDatagramSocketImpl.java:143)
>  at java.net.DatagramSocket.receive(DatagramSocket.java:812)
>  at 
> org.snmp4j.transport.DefaultUdpTransportMapping$ListenThread.run(DefaultUdpTransportMapping.java:397)
>  at java.lang.Thread.run(Thread.java:748)
> 
> I think the reason for the exception thrown is the 'appShutdown' notification 
> confirmation packet comes *after* all resources are closed. The packet is 
> processed in DefaultUdpTransportMapping.ListenThread.run() line-397 
> socketCopy.receive(packet).
> This method throws SocketException because the resources are closed, and the 
> catch at line-455 re-throws RuntimeException.
> As the result DefaultUdpTransportMapping.ListenThread is not stopped and 
> application fails to exit.
> 
> What would you suggest to fix the exception in this scenario?
> Maybe additional boolean flag in TransportMapping could be added to signal 
> WorkerTask not to process any packets if TransportMapping is closed?
> 
> Thanks,
> Mark
> 
> ___
> SNMP4J mailing list
> SNMP4J@agentpp.org
> https://oosnmp.net/mailman/listinfo/snmp4j

___
SNMP4J mailing list
SNMP4J@agentpp.org
https://oosnmp.net/mailman/listinfo/snmp4j


[SNMP4J] RuntimeException on shutdown

2018-11-15 Thread forum

I implemented notification 'appShutdown' as follows:
1. NotificationOriginatorImpl -> notify() with 'appShutdown' 
notification.

2. Snmp -> close() to release all resources.
3. Close application.

The result is exception (line numbers are for SNMP4J v2.6.2):
java.lang.RuntimeException: java.net.SocketException: socket closed
  at 
org.snmp4j.transport.DefaultUdpTransportMapping$ListenThread.run(DefaultUdpTransportMapping.java:455)

  at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: socket closed
  at 
java.net.DualStackPlainDatagramSocketImpl.socketReceiveOrPeekData(Native 
Method)
  at 
java.net.DualStackPlainDatagramSocketImpl.receive0(DualStackPlainDatagramSocketImpl.java:124)
  at 
java.net.AbstractPlainDatagramSocketImpl.receive(AbstractPlainDatagramSocketImpl.java:143)

  at java.net.DatagramSocket.receive(DatagramSocket.java:812)
  at 
org.snmp4j.transport.DefaultUdpTransportMapping$ListenThread.run(DefaultUdpTransportMapping.java:397)

  at java.lang.Thread.run(Thread.java:748)

I think the reason for the exception thrown is the 'appShutdown' 
notification confirmation packet comes *after* all resources are closed. 
The packet is processed in DefaultUdpTransportMapping.ListenThread.run() 
line-397 socketCopy.receive(packet).
This method throws SocketException because the resources are closed, and 
the catch at line-455 re-throws RuntimeException.
As the result DefaultUdpTransportMapping.ListenThread is not stopped and 
application fails to exit.


What would you suggest to fix the exception in this scenario?
Maybe additional boolean flag in TransportMapping could be added to 
signal WorkerTask not to process any packets if TransportMapping is 
closed?


Thanks,
Mark

___
SNMP4J mailing list
SNMP4J@agentpp.org
https://oosnmp.net/mailman/listinfo/snmp4j