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 2014/12/22 09:26:23 UTC

[1/3] mina git commit: Minor refactoring in Javadoc

Repository: mina
Updated Branches:
  refs/heads/2.0 59b7dbabc -> eb2786150


Minor refactoring in Javadoc

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

Branch: refs/heads/2.0
Commit: 91ec86521a6039f7832859e69ff8b53b98d095e9
Parents: 59b7dba
Author: Emmanuel Lécharny <el...@symas.com>
Authored: Mon Dec 22 09:00:55 2014 +0100
Committer: Emmanuel Lécharny <el...@symas.com>
Committed: Mon Dec 22 09:00:55 2014 +0100

----------------------------------------------------------------------
 .../mina/core/buffer/AbstractIoBuffer.java      |  3 ++
 .../org/apache/mina/core/buffer/IoBuffer.java   | 51 +++++++++++++++++---
 2 files changed, 46 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina/blob/91ec8652/mina-core/src/main/java/org/apache/mina/core/buffer/AbstractIoBuffer.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/buffer/AbstractIoBuffer.java b/mina-core/src/main/java/org/apache/mina/core/buffer/AbstractIoBuffer.java
index 0b5a397..fee0091 100644
--- a/mina-core/src/main/java/org/apache/mina/core/buffer/AbstractIoBuffer.java
+++ b/mina-core/src/main/java/org/apache/mina/core/buffer/AbstractIoBuffer.java
@@ -274,6 +274,7 @@ public abstract class AbstractIoBuffer extends IoBuffer {
 
         int end = pos + expectedRemaining;
         int newCapacity;
+        
         if (autoExpand) {
             newCapacity = IoBuffer.normalizeCapacity(end);
         } else {
@@ -366,9 +367,11 @@ public abstract class AbstractIoBuffer extends IoBuffer {
     public final IoBuffer position(int newPosition) {
         autoExpand(newPosition, 0);
         buf().position(newPosition);
+        
         if (mark > newPosition) {
             mark = -1;
         }
+        
         return this;
     }
 

http://git-wip-us.apache.org/repos/asf/mina/blob/91ec8652/mina-core/src/main/java/org/apache/mina/core/buffer/IoBuffer.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/buffer/IoBuffer.java b/mina-core/src/main/java/org/apache/mina/core/buffer/IoBuffer.java
index 19827c2..9ef8ce3 100644
--- a/mina-core/src/main/java/org/apache/mina/core/buffer/IoBuffer.java
+++ b/mina-core/src/main/java/org/apache/mina/core/buffer/IoBuffer.java
@@ -373,9 +373,9 @@ public abstract class IoBuffer implements Comparable<IoBuffer> {
      *   |       |          |
      *  pos    limit     capacity
      *  
-     * V < C :
+     * V <= C :
      * 
-     *   0       L          V
+     *   0       L          C
      *  +--------+----------+
      *  |XXXXXXXX|          |
      *  +--------+----------+
@@ -393,6 +393,8 @@ public abstract class IoBuffer implements Comparable<IoBuffer> {
      *   |       |          |            |
      *  pos    limit   oldCapacity  newCapacity
      *  
+     *  The buffer has been increased.
+     *  
      * </pre>
      * 
      * @param capacity the wanted capacity
@@ -446,7 +448,7 @@ public abstract class IoBuffer implements Comparable<IoBuffer> {
      *   |       |          |
      *  pos    limit     capacity
      *  
-     * ( pos + V)  <= L, no change :
+     * ( pos + V )  <= L, no change :
      * 
      *   0       L          C
      *  +--------+----------+
@@ -468,7 +470,7 @@ public abstract class IoBuffer implements Comparable<IoBuffer> {
      *   |           |      |
      *  pos       newlimit  newCapacity
      *  
-     *  You can now put ( L - pos + V)  bytes in the buffer.
+     *  You can now put ( L - pos + V )  bytes in the buffer.
      *  
      *  
      *  ( pos + V ) > C
@@ -515,7 +517,7 @@ public abstract class IoBuffer implements Comparable<IoBuffer> {
      *      |    |          |
      *     pos limit     capacity
      *  
-     * ( pos + V)  <= L, no change :
+     * ( pos + V )  <= L, no change :
      * 
      *      P    L          C
      *  +--------+----------+
@@ -569,10 +571,43 @@ public abstract class IoBuffer implements Comparable<IoBuffer> {
     /**
      * Changes the capacity of this buffer so this buffer occupies as less
      * memory as possible while retaining the position, limit and the buffer
-     * content between the position and limit. The capacity of the buffer never
-     * becomes less than {@link #minimumCapacity()}. The mark is discarded once
-     * the capacity changes.
+     * content between the position and limit. <br/>
+     * <b>The capacity of the buffer never becomes less than {@link #minimumCapacity()}</b></br>. 
+     * The mark is discarded once the capacity changes.<br/>
+     * Typically, a call to this method tries to remove as much unused bytes
+     * as possible, dividing by two the initial capacity until it can't without
+     * obtaining a new capacity lower than the {@link #minimumCapacity()}. For instance, if 
+     * the limit is 7 and the capacity is 36, with a minimum capacity of 8, 
+     * shrinking the buffer will left a capacity of 9 (we go down from 36 to 18, then from 18 to 9).  
      * 
+     * <pre>
+     *  Initial buffer :
+     *   
+     *  +--------+----------+
+     *  |XXXXXXXX|          |
+     *  +--------+----------+
+     *      ^    ^  ^       ^
+     *      |    |  |       |
+     *     pos   |  |    capacity
+     *           |  |
+     *           |  +-- minimumCapacity
+     *           |
+     *           +-- limit
+     * 
+     * Resulting buffer :
+     * 
+     *  +--------+--+-+
+     *  |XXXXXXXX|  | |
+     *  +--------+--+-+
+     *      ^    ^  ^ ^
+     *      |    |  | |
+     *      |    |  | +-- new capacity
+     *      |    |  |
+     *     pos   |  +-- minimum capacity
+     *           |
+     *           +-- limit
+     * </pre>
+     *           
      * @return The modified IoBuffer instance
      */
     public abstract IoBuffer shrink();


[3/3] mina git commit: Added some tests

Posted by el...@apache.org.
Added some tests

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

Branch: refs/heads/2.0
Commit: eb2786150702bd999f6fbbba5534711d0cbb6f16
Parents: 4d4bcf7
Author: Emmanuel Lécharny <el...@symas.com>
Authored: Mon Dec 22 09:07:33 2014 +0100
Committer: Emmanuel Lécharny <el...@symas.com>
Committed: Mon Dec 22 09:07:33 2014 +0100

----------------------------------------------------------------------
 .../apache/mina/core/buffer/IoBufferTest.java   | 85 ++++++++++++++++----
 .../org/apache/mina/filter/ssl/SslTest.java     | 11 ++-
 2 files changed, 77 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina/blob/eb278615/mina-core/src/test/java/org/apache/mina/core/buffer/IoBufferTest.java
----------------------------------------------------------------------
diff --git a/mina-core/src/test/java/org/apache/mina/core/buffer/IoBufferTest.java b/mina-core/src/test/java/org/apache/mina/core/buffer/IoBufferTest.java
index 238036d..8c663ca 100644
--- a/mina-core/src/test/java/org/apache/mina/core/buffer/IoBufferTest.java
+++ b/mina-core/src/test/java/org/apache/mina/core/buffer/IoBufferTest.java
@@ -43,7 +43,7 @@ import org.apache.mina.util.Bar;
 import org.junit.Test;
 
 /**
- * Tests {@link IoBuffer}.
+ * Tests the {@link IoBuffer} class.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
@@ -55,6 +55,9 @@ public class IoBufferTest {
     public static class NonserializableClass {
     }
 
+    /**
+     * Test the capacity(newCapacity) method.
+     */
     @Test
     public void testCapacity() {
         IoBuffer buffer = IoBuffer.allocate(10);
@@ -62,7 +65,7 @@ public class IoBufferTest {
         buffer.put("012345".getBytes());
         buffer.flip();
         
-        // See if we can decrease the capacity (we shouldn't)
+        // See if we can decrease the capacity (we shouldn't be able to go under the minimul capacity)
         IoBuffer newBuffer = buffer.capacity(7);
         assertEquals(10, newBuffer.capacity());
         assertEquals(buffer, newBuffer);
@@ -78,8 +81,18 @@ public class IoBufferTest {
         newBuffer.put(0, (byte)'9');
         assertEquals((byte)'9', newBuffer.get(0));
         assertEquals((byte)'9', buffer.get(0));
+        
+        // See if we can go down when the minimum capacity is below the current capacity
+        // We should not.
+        buffer = IoBuffer.allocate(10);
+        buffer.capacity(5);
+        assertEquals(10, buffer.minimumCapacity());
+        assertEquals(10, buffer.capacity());
     }
 
+    /**
+     * Test the expand(expectedRemaining) method.
+     */
     @Test
     public void testExpand() {
         IoBuffer buffer = IoBuffer.allocate(10);
@@ -151,6 +164,9 @@ public class IoBufferTest {
         assertEquals(4, newBuffer.position());
     }
 
+    /**
+     * Test the expand(position, expectedRemaining) method.
+     */
     @Test
     public void testExpandPos() {
         IoBuffer buffer = IoBuffer.allocate(10);
@@ -221,7 +237,10 @@ public class IoBufferTest {
         assertEquals(11, newBuffer.capacity());
         assertEquals(4, newBuffer.position());
     }
-    
+
+    /**
+     * Test the normalizeCapacity(requestedCapacity) method.
+     */
     @Test
     public void testNormalizeCapacity() {
         // A few sanity checks
@@ -406,6 +425,15 @@ public class IoBufferTest {
         }
     }
 
+    /**
+     * Test that we can't allocate a buffser with a negative value
+     * @throws Exception
+     */
+    @Test(expected=IllegalArgumentException.class)
+    public void testAllocateNegative() throws Exception {
+        IoBuffer.allocate(-1);
+    }
+
     @Test
     public void testAutoExpand() throws Exception {
         IoBuffer buf = IoBuffer.allocate(1);
@@ -1558,6 +1586,9 @@ public class IoBufferTest {
         assertEquals(0x0000000083838383L, buf.getUnsignedInt());
     }
 
+    /**
+     * Test the IoBuffer.putUnsignedInIndex() method.
+     */
     @Test
     public void testPutUnsignedIntIndex() {
         IoBuffer buf = IoBuffer.allocate(16);
@@ -1584,7 +1615,7 @@ public class IoBufferTest {
     }
 
     /**
-     * Test the getSlice method (even if we haven't flipped the buffer
+     * Test the getSlice method (even if we haven't flipped the buffer)
      */
     @Test
     public void testGetSlice() {
@@ -1617,22 +1648,42 @@ public class IoBufferTest {
         assertEquals(0x03, res.get());
     }
 
+    /**
+     * Test the IoBuffer.shrink() method.
+     */
     @Test
     public void testShrink() {
         IoBuffer buf = IoBuffer.allocate(36);
-        buf.minimumCapacity(0);
+        buf.put( "012345".getBytes());
+        buf.flip();
+        buf.position(4);
+        buf.minimumCapacity(8);
 
-        buf.limit(18);
-        buf.shrink();
-        buf.limit(9);
-        buf.shrink();
-        buf.limit(4);
-        buf.shrink();
-        buf.limit(2);
-        buf.shrink();
-        buf.limit(1);
-        buf.shrink();
-        buf.limit(0);
-        buf.shrink();
+        IoBuffer newBuf = buf.shrink();
+        assertEquals(4, newBuf.position());
+        assertEquals(6, newBuf.limit());
+        assertEquals(9, newBuf.capacity());
+        assertEquals(8, newBuf.minimumCapacity());
+
+        buf = IoBuffer.allocate(6);
+        buf.put( "012345".getBytes());
+        buf.flip();
+        buf.position(4);
+
+        newBuf = buf.shrink();
+        assertEquals(4, newBuf.position());
+        assertEquals(6, newBuf.limit());
+        assertEquals(6, newBuf.capacity());
+        assertEquals(6, newBuf.minimumCapacity());
+    }
+    
+    
+    /**
+     * Test the IoBuffer.position(newPosition) method.
+     */
+    @Test
+    public void testSetPosition()
+    {
+        
     }
 }

http://git-wip-us.apache.org/repos/asf/mina/blob/eb278615/mina-core/src/test/java/org/apache/mina/filter/ssl/SslTest.java
----------------------------------------------------------------------
diff --git a/mina-core/src/test/java/org/apache/mina/filter/ssl/SslTest.java b/mina-core/src/test/java/org/apache/mina/filter/ssl/SslTest.java
index 135c7e1..5f577dd 100644
--- a/mina-core/src/test/java/org/apache/mina/filter/ssl/SslTest.java
+++ b/mina-core/src/test/java/org/apache/mina/filter/ssl/SslTest.java
@@ -79,7 +79,14 @@ public class SslTest {
                 Thread.sleep(1500);
             } else if (line.startsWith("send")) {
                 System.out.println("Server got: 'send', sending 'data'");
-                session.write("data");
+                StringBuilder sb = new StringBuilder();
+                
+                for ( int i = 0; i < 10000; i++) {
+                    sb.append('A');
+                }
+                    
+                session.write(sb.toString());
+                session.close(true);
             }
         }
     }
@@ -127,7 +134,7 @@ public class SslTest {
         System.out.println("Client sending: hello");
         socket.getOutputStream().write("hello                      \n".getBytes());
         socket.getOutputStream().flush();
-        socket.setSoTimeout(10000);
+        socket.setSoTimeout(1000000);
 
         System.out.println("Client sending: send");
         socket.getOutputStream().write("send\n".getBytes());


[2/3] mina git commit: Minor Javadoc refactoring

Posted by el...@apache.org.
Minor Javadoc refactoring


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

Branch: refs/heads/2.0
Commit: 4d4bcf73a9fda1c40b13b97b752e4e5d5998ce64
Parents: 91ec865
Author: Emmanuel Lécharny <el...@symas.com>
Authored: Mon Dec 22 09:01:54 2014 +0100
Committer: Emmanuel Lécharny <el...@symas.com>
Committed: Mon Dec 22 09:01:54 2014 +0100

----------------------------------------------------------------------
 .../polling/AbstractPollingIoProcessor.java     | 94 +++++++++++---------
 .../core/session/ExpiringSessionRecycler.java   | 12 ++-
 .../mina/core/session/IoSessionRecycler.java    | 19 ++--
 .../java/org/apache/mina/util/ExpiringMap.java  | 19 ++--
 4 files changed, 79 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina/blob/4d4bcf73/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java b/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java
index a17a3a4..ad9ae5d 100644
--- a/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java
+++ b/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java
@@ -59,10 +59,11 @@ import org.slf4j.LoggerFactory;
  * developers to write an {@link IoProcessor} easily. This class is in charge of
  * active polling a set of {@link IoSession} and trigger events when some I/O
  * operation is possible.
- *
+ * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
- *
- * @param <S> the type of the {@link IoSession} this processor can handle
+ * 
+ * @param <S>
+ *            the type of the {@link IoSession} this processor can handle
  */
 public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> implements IoProcessor<S> {
     /** A logger for this class */
@@ -124,7 +125,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
     /**
      * Create an {@link AbstractPollingIoProcessor} with the given
      * {@link Executor} for handling I/Os events.
-     *
+     * 
      * @param executor
      *            the {@link Executor} for handling I/O events
      */
@@ -141,7 +142,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
      * Compute the thread ID for this class instance. As we may have different
      * classes, we store the last ID number into a Map associating the class
      * name to the last assigned ID.
-     *
+     * 
      * @return a name for the current thread, based on the class name and an
      *         incremental value, starting at 1.
      */
@@ -195,15 +196,17 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
 
     /**
      * Dispose the resources used by this {@link IoProcessor} for polling the
-     * client connections. The implementing class doDispose method will be called.
-     *
-     * @throws Exception if some low level IO error occurs
+     * client connections. The implementing class doDispose method will be
+     * called.
+     * 
+     * @throws Exception
+     *             if some low level IO error occurs
      */
     protected abstract void doDispose() throws Exception;
 
     /**
      * poll those sessions for the given timeout
-     *
+     * 
      * @param timeout
      *            milliseconds before the call timeout if no event appear
      * @return The number of session ready for read or for write
@@ -214,7 +217,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
 
     /**
      * poll those sessions forever
-     *
+     * 
      * @return The number of session ready for read or for write
      * @throws Exception
      *             if some low level IO error occurs
@@ -224,7 +227,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
     /**
      * Say if the list of {@link IoSession} polled by this {@link IoProcessor}
      * is empty
-     *
+     * 
      * @return true if at least a session is managed by this {@link IoProcessor}
      */
     protected abstract boolean isSelectorEmpty();
@@ -237,7 +240,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
     /**
      * Get an {@link Iterator} for the list of {@link IoSession} polled by this
      * {@link IoProcessor}
-     *
+     * 
      * @return {@link Iterator} of {@link IoSession}
      */
     protected abstract Iterator<S> allSessions();
@@ -252,7 +255,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
 
     /**
      * Get the state of a session (preparing, open, closed)
-     *
+     * 
      * @param session
      *            the {@link IoSession} to inspect
      * @return the state of the session
@@ -261,7 +264,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
 
     /**
      * Is the session ready for writing
-     *
+     * 
      * @param session
      *            the session queried
      * @return true is ready, false if not ready
@@ -270,7 +273,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
 
     /**
      * Is the session ready for reading
-     *
+     * 
      * @param session
      *            the session queried
      * @return true is ready, false if not ready
@@ -279,7 +282,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
 
     /**
      * register a session for writing
-     *
+     * 
      * @param session
      *            the session registered
      * @param isInterested
@@ -289,7 +292,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
 
     /**
      * register a session for reading
-     *
+     * 
      * @param session
      *            the session registered
      * @param isInterested
@@ -299,7 +302,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
 
     /**
      * is this session registered for reading
-     *
+     * 
      * @param session
      *            the session queried
      * @return true is registered for reading
@@ -308,7 +311,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
 
     /**
      * is this session registered for writing
-     *
+     * 
      * @param session
      *            the session queried
      * @return true is registered for writing
@@ -317,15 +320,17 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
 
     /**
      * Initialize the polling of a session. Add it to the polling process.
-     *
-     * @param session the {@link IoSession} to add to the polling
-     * @throws Exception any exception thrown by the underlying system calls
+     * 
+     * @param session
+     *            the {@link IoSession} to add to the polling
+     * @throws Exception
+     *             any exception thrown by the underlying system calls
      */
     protected abstract void init(S session) throws Exception;
 
     /**
      * Destroy the underlying client socket handle
-     *
+     * 
      * @param session
      *            the {@link IoSession}
      * @throws Exception
@@ -336,7 +341,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
     /**
      * Reads a sequence of bytes from a {@link IoSession} into the given
      * {@link IoBuffer}. Is called when the session was found ready for reading.
-     *
+     * 
      * @param session
      *            the session to read
      * @param buf
@@ -350,7 +355,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
     /**
      * Write a sequence of bytes to a {@link IoSession}, means to be called when
      * a session was found ready for writing.
-     *
+     * 
      * @param session
      *            the session to write
      * @param buf
@@ -369,7 +374,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
      * isn't supporting system calls like sendfile(), you can throw a
      * {@link UnsupportedOperationException} so the file will be send using
      * usual {@link #write(AbstractIoSession, IoBuffer, int)} call.
-     *
+     * 
      * @param session
      *            the session to write
      * @param region
@@ -475,7 +480,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
      * In the case we are using the java select() method, this method is used to
      * trash the buggy selector and create a new one, registring all the sockets
      * on it.
-     *
+     * 
      * @throws IOException
      *             If we got an exception
      */
@@ -485,7 +490,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
      * Check that the select() has not exited immediately just because of a
      * broken connection. In this case, this is a standard case, and we just
      * have to loop.
-     *
+     * 
      * @return true if a connection has been brutally closed.
      * @throws IOException
      *             If we got an exception
@@ -495,7 +500,7 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
     /**
      * Loops over the new sessions blocking queue and returns the number of
      * sessions which are effectively created
-     *
+     * 
      * @return The number of new sessions
      */
     private int handleNewSessions() {
@@ -512,12 +517,11 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
     }
 
     /**
-     * Process a new session :
-     * - initialize it
-     * - create its chain
-     * - fire the CREATED listeners if any
-     *
-     * @param session The session to create
+     * Process a new session : - initialize it - create its chain - fire the
+     * CREATED listeners if any
+     * 
+     * @param session
+     *            The session to create
      * @return true if the session has been registered
      */
     private boolean addNow(S session) {
@@ -759,7 +763,8 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
         }
 
         do {
-            S session = flushingSessions.poll(); // the same one with firstSession
+            S session = flushingSessions.poll(); // the same one with
+                                                 // firstSession
 
             if (session == null) {
                 // Just in case ... It should not happen.
@@ -1024,7 +1029,8 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
 
             // As we have handled one session, decrement the number of
             // remaining sessions. The OPENING session will be processed
-            // with the next select(), as the queue size has been decreased, even
+            // with the next select(), as the queue size has been decreased,
+            // even
             // if the session has been pushed at the end of the queue
             queueSize--;
         }
@@ -1053,9 +1059,8 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
 
     /**
      * The main loop. This is the place in charge to poll the Selector, and to
-     * process the active sessions. It's done in
-     * - handle the newly created sessions
-     * -
+     * process the active sessions. It's done in - handle the newly created
+     * sessions -
      */
     private class Processor implements Runnable {
         public void run() {
@@ -1092,9 +1097,11 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
                             // spinning.
                             // Basically, there is a race condition
                             // which causes a closing file descriptor not to be
-                            // considered as available as a selected channel, but
+                            // considered as available as a selected channel,
+                            // but
                             // it stopped the select. The next time we will
-                            // call select(), it will exit immediately for the same
+                            // call select(), it will exit immediately for the
+                            // same
                             // reason, and do so forever, consuming 100%
                             // CPU.
                             // We have to destroy the selector, and
@@ -1117,7 +1124,8 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im
                     // Now, if we have had some incoming or outgoing events,
                     // deal with them
                     if (selected > 0) {
-                        //LOG.debug("Processing ..."); // This log hurts one of the MDCFilter test...
+                        // LOG.debug("Processing ..."); // This log hurts one of
+                        // the MDCFilter test...
                         process();
                     }
 

http://git-wip-us.apache.org/repos/asf/mina/blob/4d4bcf73/mina-core/src/main/java/org/apache/mina/core/session/ExpiringSessionRecycler.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/session/ExpiringSessionRecycler.java b/mina-core/src/main/java/org/apache/mina/core/session/ExpiringSessionRecycler.java
index 90a0d9a..5c5bfce 100644
--- a/mina-core/src/main/java/org/apache/mina/core/session/ExpiringSessionRecycler.java
+++ b/mina-core/src/main/java/org/apache/mina/core/session/ExpiringSessionRecycler.java
@@ -27,12 +27,11 @@ import org.apache.mina.util.ExpiringMap;
 /**
  * An {@link IoSessionRecycler} with sessions that time out on inactivity.
  *
- * TODO Document me.
- *
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  * @org.apache.xbean.XBean
  */
 public class ExpiringSessionRecycler implements IoSessionRecycler {
+    /** A map used to store the session */
     private ExpiringMap<SocketAddress, IoSession> sessionMap;
 
     private ExpiringMap<SocketAddress, IoSession>.Expirer mapExpirer;
@@ -51,6 +50,9 @@ public class ExpiringSessionRecycler implements IoSessionRecycler {
         sessionMap.addExpirationListener(new DefaultExpirationListener());
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public void put(IoSession session) {
         mapExpirer.startExpiringIfNotStarted();
 
@@ -61,10 +63,16 @@ public class ExpiringSessionRecycler implements IoSessionRecycler {
         }
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public IoSession recycle(SocketAddress remoteAddress) {
         return sessionMap.get(remoteAddress);
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public void remove(IoSession session) {
         sessionMap.remove(session.getRemoteAddress());
     }

http://git-wip-us.apache.org/repos/asf/mina/blob/4d4bcf73/mina-core/src/main/java/org/apache/mina/core/session/IoSessionRecycler.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/session/IoSessionRecycler.java b/mina-core/src/main/java/org/apache/mina/core/session/IoSessionRecycler.java
index 61d9e3b..d10d0d7 100644
--- a/mina-core/src/main/java/org/apache/mina/core/session/IoSessionRecycler.java
+++ b/mina-core/src/main/java/org/apache/mina/core/session/IoSessionRecycler.java
@@ -37,14 +37,23 @@ public interface IoSessionRecycler {
      * sessions.
      */
     static IoSessionRecycler NOOP = new IoSessionRecycler() {
+        /**
+         * {@inheritDoc}
+         */
         public void put(IoSession session) {
             // Do nothing
         }
 
+        /**
+         * {@inheritDoc}
+         */
         public IoSession recycle(SocketAddress remoteAddress) {
             return null;
         }
 
+        /**
+         * {@inheritDoc}
+         */
         public void remove(IoSession session) {
             // Do nothing
         }
@@ -53,17 +62,14 @@ public interface IoSessionRecycler {
     /**
      * Called when the underlying transport creates or writes a new {@link IoSession}.
      *
-     * @param session
-     *            the new {@link IoSession}.
+     * @param session the new {@link IoSession}.
      */
     void put(IoSession session);
 
     /**
      * Attempts to retrieve a recycled {@link IoSession}.
      *
-     * @param remoteAddress
-     *            the remote socket address of the {@link IoSession} the
-     *            transport wants to recycle.
+     * @param remoteAddress the remote socket address of the {@link IoSession} the transport wants to recycle.
      * @return a recycled {@link IoSession}, or null if one cannot be found.
      */
     IoSession recycle(SocketAddress remoteAddress);
@@ -71,8 +77,7 @@ public interface IoSessionRecycler {
     /**
      * Called when an {@link IoSession} is explicitly closed.
      *
-     * @param session
-     *            the new {@link IoSession}.
+     * @param session the new {@link IoSession}.
      */
     void remove(IoSession session);
 }

http://git-wip-us.apache.org/repos/asf/mina/blob/4d4bcf73/mina-core/src/main/java/org/apache/mina/util/ExpiringMap.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/util/ExpiringMap.java b/mina-core/src/main/java/org/apache/mina/util/ExpiringMap.java
index 7e08b4a..d06641a 100644
--- a/mina-core/src/main/java/org/apache/mina/util/ExpiringMap.java
+++ b/mina-core/src/main/java/org/apache/mina/util/ExpiringMap.java
@@ -35,15 +35,10 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
 public class ExpiringMap<K, V> implements Map<K, V> {
-
-    /**
-     * The default value, 60
-     */
+    /** The default value, 60 seconds */
     public static final int DEFAULT_TIME_TO_LIVE = 60;
 
-    /**
-     * The default value, 1
-     */
+    /** The default value, 1 second */
     public static final int DEFAULT_EXPIRATION_INTERVAL = 1;
 
     private static volatile int expirerCount = 1;
@@ -67,8 +62,7 @@ public class ExpiringMap<K, V> implements Map<K, V> {
      * Creates a new instance of ExpiringMap using the supplied 
      * time-to-live value and the default value for DEFAULT_EXPIRATION_INTERVAL
      *
-     * @param timeToLive
-     *  The time-to-live value (seconds)
+     * @param timeToLive The time-to-live value (seconds)
      */
     public ExpiringMap(int timeToLive) {
         this(timeToLive, DEFAULT_EXPIRATION_INTERVAL);
@@ -78,10 +72,8 @@ public class ExpiringMap<K, V> implements Map<K, V> {
      * Creates a new instance of ExpiringMap using the supplied values and 
      * a {@link ConcurrentHashMap} for the internal data structure.
      *
-     * @param timeToLive
-     *  The time-to-live value (seconds)
-     * @param expirationInterval
-     *  The time between checks to see if a value should be removed (seconds)
+     * @param timeToLive The time-to-live value (seconds)
+     * @param expirationInterval The time between checks to see if a value should be removed (seconds)
      */
     public ExpiringMap(int timeToLive, int expirationInterval) {
         this(new ConcurrentHashMap<K, ExpiringObject>(), new CopyOnWriteArrayList<ExpirationListener<V>>(), timeToLive,
@@ -100,6 +92,7 @@ public class ExpiringMap<K, V> implements Map<K, V> {
 
     public V put(K key, V value) {
         ExpiringObject answer = delegate.put(key, new ExpiringObject(key, value, System.currentTimeMillis()));
+        
         if (answer == null) {
             return null;
         }