Do not consider PortUnreachableException to require channel closure
Motivation: When a datagram packet is sent to a destination where nobody actually listens to, the server O/S will respond with an ICMP Port Unreachable packet. The ICMP Port Unreachable packet is translated into PortUnreachableException by JDK. PortUnreachableException is not a harmful exception that prevents a user from sending a datagram. Therefore, we should not close a datagram channel when PortUnreachableException is caught. Modifications: - Do not close a channel when the caught exception is PortUnreachableException. Result: A datagram channel is not closed unexpectedly anymore.
This commit is contained in:
parent
d9739126f2
commit
75ed693794
@ -22,6 +22,7 @@ import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.ServerChannel;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.PortUnreachableException;
|
||||
import java.nio.channels.SelectableChannel;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.util.ArrayList;
|
||||
@ -96,7 +97,7 @@ public abstract class AbstractNioMessageChannel extends AbstractNioChannel {
|
||||
pipeline.fireChannelReadComplete();
|
||||
|
||||
if (exception != null) {
|
||||
if (exception instanceof IOException) {
|
||||
if (exception instanceof IOException && !(exception instanceof PortUnreachableException)) {
|
||||
// ServerChannel should not be closed even on IOException because it can often continue
|
||||
// accepting incoming connections. (e.g. too many open files)
|
||||
closed = !(AbstractNioMessageChannel.this instanceof ServerChannel);
|
||||
|
Loading…
Reference in New Issue
Block a user