MINA
  1. MINA
  2. DIRMINA-54

ProtocalSession begins reading(decoding) before the session has been opened

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.7.1
    • Fix Version/s: 0.7.2
    • Component/s: None
    • Labels:
      None
    • Environment:
      windows xp using TCP/IP

      Description

      With a local connection, I have seen it over the network but not as often, MINA regularly will call the Decoder.decode(..) method before it calls ProtocolHandler.sessionOpened

      Inside the decode, I use the protocolSession attachment, which is set in the ProtocolHandler.sessionOpened

      so on these occassions, i am unable to read properly because my attachment object is not available.

      I have an ugly hack for my needs that requires synchronizing on the protocolsession in both methods, but would think that MINA should properly manage the lifecycle to gaurantee that sessionOpened is always called before any read/writes on the protocolsession.

        Activity

        Daniel Fellars created issue -
        Hide
        Trustin Lee added a comment -

        Doesn't ProtocolDecoder.decode() provide ProtocolSession as a parameter?

        Protocol codecs exists between I/O layer and Protocol layer, and they can be called before sessionOpened(ProtocolSession) is called. If you want to set something up before all I/O starts, you can implement sessionCreated(ProtocolSession) handler method.

        By the way, sessionCreated(ProtocolSession) is not being called due to its bug. I'll fix it as soon as possible and comment here.

        Thanks,
        Trustin

        Show
        Trustin Lee added a comment - Doesn't ProtocolDecoder.decode() provide ProtocolSession as a parameter? Protocol codecs exists between I/O layer and Protocol layer, and they can be called before sessionOpened(ProtocolSession) is called. If you want to set something up before all I/O starts, you can implement sessionCreated(ProtocolSession) handler method. By the way, sessionCreated(ProtocolSession) is not being called due to its bug. I'll fix it as soon as possible and comment here. Thanks, Trustin
        Trustin Lee made changes -
        Field Original Value New Value
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        Trustin Lee added a comment -

        I checked in the fix and undated 0.7.2-SNAPSHOT. Could you please test it?

        Thanks,
        Trustin

        Show
        Trustin Lee added a comment - I checked in the fix and undated 0.7.2-SNAPSHOT. Could you please test it? Thanks, Trustin
        Trustin Lee made changes -
        Resolution Fixed [ 1 ]
        Fix Version/s 0.7.2 [ 11180 ]
        Status In Progress [ 3 ] Resolved [ 5 ]
        Hide
        Daniel Fellars added a comment -

        Thanks Trustin,

        From initial testing, I now get the sessionCreated called first, so I do all my initialization there before any decoding occurs.

        For clarification, what would be the difference between the sessionCreated and sessionOpened, would there be times when sessionOpened is called and not sessionCreated?

        Thanks for you speedy reply on this great product.

        Dan

        Show
        Daniel Fellars added a comment - Thanks Trustin, From initial testing, I now get the sessionCreated called first, so I do all my initialization there before any decoding occurs. For clarification, what would be the difference between the sessionCreated and sessionOpened, would there be times when sessionOpened is called and not sessionCreated? Thanks for you speedy reply on this great product. Dan
        Hide
        Trustin Lee added a comment -

        sessionOpened is not called if you're using stateless transport types like Datagram. SessionCreated is always called. The difference between sessionCreated and sessionOpened is that sessionCreated is not filtered by filter chains so that it is always called in the same thread with which the selector thread runs in.

        Could you please close this issue if it is resolved?

        Thanks,
        Trustin

        Show
        Trustin Lee added a comment - sessionOpened is not called if you're using stateless transport types like Datagram. SessionCreated is always called. The difference between sessionCreated and sessionOpened is that sessionCreated is not filtered by filter chains so that it is always called in the same thread with which the selector thread runs in. Could you please close this issue if it is resolved? Thanks, Trustin
        Hide
        Daniel Fellars added a comment -

        sessionCreated now being called

        Show
        Daniel Fellars added a comment - sessionCreated now being called
        Daniel Fellars made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development