Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-543

Incorrect sessionCreated event order in VmPipe transport

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.9, 1.1.6, 2.0.0-M1
    • Fix Version/s: 1.0.10, 1.1.7, 2.0.0-M2
    • Component/s: Transport
    • Labels:
      None

      Description

      The following unit test method fails because sessionOpened can be called before sessionCreated.

      public void testSessionCreated() throws Exception {
      final Semaphore semaphore = new Semaphore(0);
      final StringBuffer stringBuffer = new StringBuffer();
      VmPipeAcceptor vmPipeAcceptor = new VmPipeAcceptor();
      final VmPipeAddress vmPipeAddress = new VmPipeAddress(12345);
      vmPipeAcceptor.setHandler(new IoHandlerAdapter() {
      @Override
      public void sessionCreated(IoSession session) throws Exception

      { // pretend we are doing some time-consuming work. For // performance reasons, you would never want to do time // consuming work in sessionCreated. // However, this increases the likelihood of the timing bug. Thread.sleep(1000); stringBuffer.append("A"); }

      @Override
      public void sessionOpened(IoSession session) throws Exception

      { stringBuffer.append("B"); }

      @Override
      public void messageReceived(IoSession session, Object message)
      throws Exception

      { stringBuffer.append("C"); }

      @Override
      public void sessionClosed(IoSession session) throws Exception

      { stringBuffer.append("D"); semaphore.release(); }

      });
      vmPipeAcceptor.bind(vmPipeAddress);

      final VmPipeConnector vmPipeConnector = new VmPipeConnector();
      vmPipeConnector.getFilterChain().addLast("executor", new ExecutorFilter());
      vmPipeConnector.setHandler(new IoHandlerAdapter() {
      @Override
      public void sessionOpened(IoSession session) throws Exception

      { session.write(IoBuffer.wrap(new byte[1])); }

      });
      ConnectFuture connectFuture = vmPipeConnector.connect(vmPipeAddress).awaitUninterruptibly();
      Thread.sleep(3000);
      connectFuture.getSession().close();
      semaphore.tryAcquire(1, TimeUnit.SECONDS);
      vmPipeAcceptor.unbind(vmPipeAddress);
      Assert.assertEquals("ABCD", stringBuffer.toString());
      }

        Attachments

          Activity

            People

            • Assignee:
              trustin Trustin Lee
              Reporter:
              trustin Trustin Lee
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: