Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-393

Override decodeLast instead of checking readableBytes

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major Major
    • 4.1.0.ALPHA3
    • 4.1.0.ALPHA2
    • Remote Protocols
    • None

      Replace readableBytes hack when clients disconnect from the channel with implementing decodeLast accordingly. See below for more details

      <galderz> one final thing,
      <galderz> one thing I've spotted is that when a clients disconnect
      <trustin> (overriden that is)
      <galderz> my ReplayingDecoder.decode is called with nothing to read
      <galderz> iow, trying to read a byte throws a rather noisy ChannelClosedException or something like that
      <galderz> so, to get around this,
      <galderz> i created in the netty ChannelBufferAdapter that we have
      <galderz> i created a method called readableBytes that computes
      <galderz> buffer.writerIndex - buffer.readerIndex
      <trustin> hmmm
      <trustin> actually, ReplayingDecoder calls its decodeLast() method when the connection is closed.
      <galderz> calling buffer,readableBytes in the ReplayingDecoder would not really tell me what's behing
      <trustin> but the default implementation of decodeLast() is delegate the call to decode();.
      <galderz> right, so maybe I need to override decodeLast?
      <galderz> what I'm doing right now looks v hacky
      <trustin> yeah if you do not want to be notified when the connection is closed in your decoder
      <trustin> just override decodeLast() an do nothing there.
      <galderz> right, i'll check that out as well
      <trustin> The default decodeLast() implementation is reasonable with FrameDecoder, but I guess it seems to confuse the user with ReplayingDecoder

      • manik has quit (Quit: manik)
        <galderz> i think so, cos readableBytes gives me Integer.Max in those situations
        <trustin> when disconnected
        <trustin> readableBytes() will give the actual readable bytes
        <galderz> yeah, when disconnected
        <trustin> instead of Integer.MAX
        <galderz> it was definitely not giving me 0
        <galderz> it was giving something really big
        <trustin> oh I see.
        <trustin> Let me know if you still have to problem after overriding decodeLast()
        <trustin> to -> the
        <galderz> sure, thanks a million for this chat

            rh-ee-galder Galder ZamarreƱo
            rh-ee-galder Galder ZamarreƱo
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: