You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by el...@apache.org on 2016/08/11 15:28:13 UTC

[03/10] mina git commit: CLose the channel only when it's not already closed

CLose the channel only when it's not already closed


Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/0a28b4ea
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/0a28b4ea
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/0a28b4ea

Branch: refs/heads/2.0
Commit: 0a28b4eae07e9d348ec6ecd0b004888b698d9818
Parents: 3b6c446
Author: Emmanuel L�charny <el...@symas.com>
Authored: Thu Aug 11 16:26:46 2016 +0200
Committer: Emmanuel L�charny <el...@symas.com>
Committed: Thu Aug 11 16:26:46 2016 +0200

----------------------------------------------------------------------
 .../org/apache/mina/transport/socket/nio/NioProcessor.java  | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina/blob/0a28b4ea/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioProcessor.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioProcessor.java b/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioProcessor.java
index f621bcf..8202e18 100644
--- a/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioProcessor.java
+++ b/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioProcessor.java
@@ -135,11 +135,16 @@ public final class NioProcessor extends AbstractPollingIoProcessor<NioSession> {
     @Override
     protected void destroy(NioSession session) throws Exception {
         ByteChannel ch = session.getChannel();
+        
         SelectionKey key = session.getSelectionKey();
+        
         if (key != null) {
             key.cancel();
         }
-        ch.close();
+        
+        if ( ch.isOpen() ) {
+            ch.close();
+        }
     }
 
     /**
@@ -313,7 +318,7 @@ public final class NioProcessor extends AbstractPollingIoProcessor<NioSession> {
     }
 
     @Override
-    protected int write(NioSession session, IoBuffer buf, int length) throws Exception {
+    protected int write(NioSession session, IoBuffer buf, int length) throws IOException {
         if (buf.remaining() <= length) {
             return session.getChannel().write(buf.buf());
         }