You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by jv...@apache.org on 2012/11/22 23:56:32 UTC

svn commit: r1412706 - in /mina/mina/trunk/core/src/main/java/org/apache/mina: session/AbstractIoSession.java transport/nio/NioSelectorLoop.java transport/nio/NioTcpSession.java

Author: jvermillard
Date: Thu Nov 22 22:56:31 2012
New Revision: 1412706

URL: http://svn.apache.org/viewvc?rev=1412706&view=rev
Log:
exception cleanup

Modified:
    mina/mina/trunk/core/src/main/java/org/apache/mina/session/AbstractIoSession.java
    mina/mina/trunk/core/src/main/java/org/apache/mina/transport/nio/NioSelectorLoop.java
    mina/mina/trunk/core/src/main/java/org/apache/mina/transport/nio/NioTcpSession.java

Modified: mina/mina/trunk/core/src/main/java/org/apache/mina/session/AbstractIoSession.java
URL: http://svn.apache.org/viewvc/mina/mina/trunk/core/src/main/java/org/apache/mina/session/AbstractIoSession.java?rev=1412706&r1=1412705&r2=1412706&view=diff
==============================================================================
--- mina/mina/trunk/core/src/main/java/org/apache/mina/session/AbstractIoSession.java (original)
+++ mina/mina/trunk/core/src/main/java/org/apache/mina/session/AbstractIoSession.java Thu Nov 22 22:56:31 2012
@@ -628,7 +628,7 @@ public abstract class AbstractIoSession 
     // ------------------------------------------------------------------------
 
     /** send a caught exception to the {@link IoHandler} (if any) */
-    private void processException(final Throwable t) {
+    protected void processException(final Throwable t) {
         LOG.debug("caught session exception ", t);
         final IoHandler handler = getService().getIoHandler();
         if (handler != null) {

Modified: mina/mina/trunk/core/src/main/java/org/apache/mina/transport/nio/NioSelectorLoop.java
URL: http://svn.apache.org/viewvc/mina/mina/trunk/core/src/main/java/org/apache/mina/transport/nio/NioSelectorLoop.java?rev=1412706&r1=1412705&r2=1412706&view=diff
==============================================================================
--- mina/mina/trunk/core/src/main/java/org/apache/mina/transport/nio/NioSelectorLoop.java (original)
+++ mina/mina/trunk/core/src/main/java/org/apache/mina/transport/nio/NioSelectorLoop.java Thu Nov 22 22:56:31 2012
@@ -230,7 +230,6 @@ public class NioSelectorLoop implements 
                     }
                 } catch (final Exception e) {
                     logger.error("Unexpected exception : ", e);
-                    e.printStackTrace();
                 }
             }
         }

Modified: mina/mina/trunk/core/src/main/java/org/apache/mina/transport/nio/NioTcpSession.java
URL: http://svn.apache.org/viewvc/mina/mina/trunk/core/src/main/java/org/apache/mina/transport/nio/NioTcpSession.java?rev=1412706&r1=1412705&r2=1412706&view=diff
==============================================================================
--- mina/mina/trunk/core/src/main/java/org/apache/mina/transport/nio/NioTcpSession.java (original)
+++ mina/mina/trunk/core/src/main/java/org/apache/mina/transport/nio/NioTcpSession.java Thu Nov 22 22:56:31 2012
@@ -195,6 +195,7 @@ public class NioTcpSession extends Abstr
             channel.close();
         } catch (final IOException e) {
             LOG.error("Exception while closing the channel : ", e);
+            processException(e);
         }
     }
 
@@ -208,8 +209,8 @@ public class NioTcpSession extends Abstr
     }
 
     /**
-     * Process a read operation : read the data from the channel and push
-     * them to the chain.
+     * Process a read operation : read the data from the channel and push them to the chain.
+     * 
      * @param readBuffer The buffer that will contain the read data
      */
     private void processRead(final ByteBuffer readBuffer) {
@@ -254,12 +255,13 @@ public class NioTcpSession extends Abstr
             }
         } catch (final IOException e) {
             LOG.error("Exception while reading : ", e);
+            processException(e);
         }
     }
 
     /**
-     * Process a write operation. This will be executed only because the session
-     * has something to write into the channel.
+     * Process a write operation. This will be executed only because the session has something to write into the
+     * channel.
      */
     private void processWrite() {
         try {
@@ -320,12 +322,12 @@ public class NioTcpSession extends Abstr
                 } else {
                     // output socket buffer is full, we need
                     // to give up until next selection for
-                    // writing. 
+                    // writing.
                     break;
                 }
             } while (!writeQueue.isEmpty());
 
-            // We may have exited from the loop for some other reason 
+            // We may have exited from the loop for some other reason
             // that an empty queue
             // if the session is no more interested in writing, we need
             // to stop listening for OP_WRITE events
@@ -343,12 +345,13 @@ public class NioTcpSession extends Abstr
                         selectorLoop.modifyRegistration(false, !isReadSuspended(), false, this, channel);
                     }
                 } else {
-                    // We have some more data to write : the channel OP_WRITE interest remains 
+                    // We have some more data to write : the channel OP_WRITE interest remains
                     // as it was.
                 }
             }
         } catch (final IOException e) {
             LOG.error("Exception while reading : ", e);
+            processException(e);
         }
     }