zhoujian2030 / jdiameter

Automatically exported from code.google.com/p/jdiameter
0 stars 0 forks source link

Fix TCPTransportClient for all OS's for detecting closed connections #48

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1)  it seems that the socketChannel API works differently in different OS's 
(Maybe a JDK error?) - we found that socketChannel.isConnected() sometimes 
returns true even though socketChannel.isOpen() returns false. This means that 
TCPTransportClient.java: isConnected() sometimes returns true even though the 
socketChannel is not open - this results in 
org.jdiameter.server.impl.PeerImpl.java:215 not finding the correct connection 
as it think the old connection is still open.  

Suggested fix is to change TCPTransportClient.java: isConnected():

-    return socketChannel != null && socketChannel.isConnected();
+    return socketChannel != null && socketChannel.isConnected() && 
socketChannel.isOpen();

Original issue reported on code.google.com by richgood...@gmail.com on 23 Oct 2013 at 8:13

GoogleCodeExporter commented 9 years ago
It seems that with NIO isConnected() returns true if the socket was ever 
connected, although javadoc doesn't seem to indicate that way. Anyway, this is 
the right thing to do, making this more reliable.

Original comment by brainslog on 4 Jul 2014 at 12:37

GoogleCodeExporter commented 9 years ago
This issue was updated by revision d069d51a77ad.

Fixed as suggested.

Original comment by brainslog on 4 Jul 2014 at 12:55