This is an automated email from the ASF dual-hosted git repository.

elecharny pushed a commit to branch 2.1.X
in repository https://gitbox.apache.org/repos/asf/mina.git


The following commit(s) were added to refs/heads/2.1.X by this push:
     new 86f0b4c54 Updated the IoSession.read() method javadoc. Cleanup of the 
DIRMINA777 test
86f0b4c54 is described below

commit 86f0b4c545c6e51183581062c2acdd6d945a0436
Author: emmanuel lecharny <[email protected]>
AuthorDate: Wed Oct 16 11:23:24 2024 +0200

    Updated the IoSession.read() method javadoc.
    Cleanup of the DIRMINA777 test
---
 .../src/main/java/org/apache/mina/core/session/IoSession.java    | 9 ++++++---
 .../org/apache/mina/transport/socket/nio/DIRMINA777Test.java     | 3 ++-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git 
a/mina-core/src/main/java/org/apache/mina/core/session/IoSession.java 
b/mina-core/src/main/java/org/apache/mina/core/session/IoSession.java
index 8d09ddccc..fcf96e391 100644
--- a/mina-core/src/main/java/org/apache/mina/core/session/IoSession.java
+++ b/mina-core/src/main/java/org/apache/mina/core/session/IoSession.java
@@ -114,18 +114,21 @@ public interface IoSession {
     TransportMetadata getTransportMetadata();
 
     /**
-     * TODO This javadoc is wrong. The return tag should be short.
-     * 
      * @return a {@link ReadFuture} which is notified when a new message is
      * received, the connection is closed or an exception is caught.  This
      * operation is especially useful when you implement a client application.
-     * TODO : Describe here how we enable this feature.
+     * 
      * However, please note that this operation is disabled by default and
      * throw {@link IllegalStateException} because all received events must be
      * queued somewhere to support this operation, possibly leading to memory
      * leak.  This means you have to keep calling {@link #read()} once you
      * enabled this operation.  To enable this operation, please call
      * {@link IoSessionConfig#setUseReadOperation(boolean)} with {@code true}.
+     * 
+     * Side note: the {@link IoSessionConfig#setUseReadOperation(boolean)} 
call 
+     * MUST be set before the session is opened, otherwise you might have a 
race 
+     * condition if you write a message in {@link 
IoHandler#sessionOpened(IoSession)}
+     * event, as this message could be written before the read hook can be set.
      *
      * @throws IllegalStateException if
      * {@link IoSessionConfig#setUseReadOperation(boolean) useReadOperation}
diff --git 
a/mina-core/src/test/java/org/apache/mina/transport/socket/nio/DIRMINA777Test.java
 
b/mina-core/src/test/java/org/apache/mina/transport/socket/nio/DIRMINA777Test.java
index 1e805700f..2a9684262 100644
--- 
a/mina-core/src/test/java/org/apache/mina/transport/socket/nio/DIRMINA777Test.java
+++ 
b/mina-core/src/test/java/org/apache/mina/transport/socket/nio/DIRMINA777Test.java
@@ -69,12 +69,13 @@ public class DIRMINA777Test {
                 throw connectFuture.getException();
             }
             
-            connectFuture.getSession().getConfig().setUseReadOperation(true);
             ReadFuture readFuture = connectFuture.getSession().read();
             readFuture.awaitUninterruptibly();
+
             if (readFuture.getException() != null) {
                 throw readFuture.getException();
             }
+            
             IoBuffer message = (IoBuffer)readFuture.getMessage();
             assertEquals(1, message.remaining());
             assertEquals(125,message.get());

Reply via email to