Avro
  1. Avro
  2. AVRO-705

DirectBinaryDecoder not correctly re-initialized with reuse option

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.4.1
    • Fix Version/s: 1.5.0
    • Component/s: java
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      Calling DecoderFactory.createBinaryDecoder(InputStream in, BinaryDecoder reuse) with reuse being a non null DirectBinaryDecoder, this DirectBinaryDecoder is simply reinitialized by a call to DirectBinaryDecoder.init which reinitializes the internal InputStream.

      The problem is that the byteReader attribute of DirectBinaryDecoder is not reinitialized and still points to the previously assigned ByteBufferInputStream

      The following is a proposition of correction at rev 1041110:

          private ByteReader byteReader;
      
          DirectBinaryDecoder(InputStream in) {
              super();
              init(in);
          }
      
          @Override
          public void init(InputStream in) {
              this.in = in;
              byteReader = (in instanceof ByteBufferInputStream)
                      ? new ReuseByteReader((ByteBufferInputStream) in)
                      : new ByteReader();
          }
      
      
      1. AVRO-705.patch
        3 kB
        Thiruvalluvan M. G.

        Activity

        Hide
        Doug Cutting added a comment -

        I just committed this. Thanks, Gilles & Thiru!

        Show
        Doug Cutting added a comment - I just committed this. Thanks, Gilles & Thiru!
        Hide
        Doug Cutting added a comment -

        +1 Looks good and passes tests for me.

        Show
        Doug Cutting added a comment - +1 Looks good and passes tests for me.
        Hide
        Thiruvalluvan M. G. added a comment -

        Good catch!

        Added a test that catches the bug and fixed the bug as well.

        Show
        Thiruvalluvan M. G. added a comment - Good catch! Added a test that catches the bug and fixed the bug as well.

          People

          • Assignee:
            Thiruvalluvan M. G.
            Reporter:
            Gilles Gaillard
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development