Unnecessary automatic adjustment of read buffer in SocketIoProcessor
--------------------------------------------------------------------

                 Key: DIRMINA-458
                 URL: https://issues.apache.org/jira/browse/DIRMINA-458
             Project: MINA
          Issue Type: Bug
          Components: Transport
    Affects Versions: 1.1.3, 1.0.6
            Reporter: Trustin Lee
            Assignee: Trustin Lee
            Priority: Minor
             Fix For: 1.1.4, 1.0.7


The following code shows that SocketIoProcessor decreases the readBuffer 
property unnecessary at a certain case:

import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;

import org.apache.mina.common.ByteBuffer;
import org.apache.mina.common.IoHandlerAdapter;
import org.apache.mina.common.IoSession;
import org.apache.mina.transport.socket.nio.SocketAcceptor;

public class Main {
    
    private static final int SERVER_PORT = 1234;
    
    public static void main(String args[]) throws Exception {
        SocketAcceptor acceptor = new SocketAcceptor();
        
acceptor.getDefaultConfig().getSessionConfig().setReceiveBufferSize(8192);
        acceptor.bind(new InetSocketAddress(SERVER_PORT), new 
IoHandlerAdapter() {
            @Override
            public void messageReceived(IoSession session, Object o) {
                ByteBuffer b = ((ByteBuffer) o);
                System.out.println("" + b.remaining() + " / " + b.capacity());
            }
        });
        
        Socket s = new Socket("localhost", SERVER_PORT);
        OutputStream out = s.getOutputStream();
        for (int i = 0; i < 5; i++) {
            out.write(new byte[200]);
            Thread.sleep(100);
        }

        for (int i = 0; i < 5; i++) {
            out.write(new byte[3000]);
            Thread.sleep(100);
        }
        
        System.exit(0);
    }
}

OUTPUT:

400 / 1024
200 / 512
200 / 256
200 / 256
256 / 256
512 / 512
1024 / 1024
1208 / 2048
2048 / 2048
952 / 4096
2048 / 2048
952 / 4096
2048 / 2048
952 / 4096
2048 / 2048
952 / 4096

Expected behvaior:

The readBuffer property should stay at 4096.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to