Giter Club home page Giter Club logo

avro-netty's People

Contributors

milenkovicm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

avro-netty's Issues

Is necessary to handle TCP packet splicing in AvroDecoder?

Hi, I have a question about the demo decoder in README.

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        //Do we need to handle TCP splicing here before DatumReader read?
        final NettyByteBufDecoder decoder = new NettyByteBufDecoder(in);
        final DatumReader<GenericRecord> reader = new GenericDatumReader<>(schema);
        try {
            final GenericRecord record = reader.read(null, decoder);
            out.add(record);
        } catch (final IOException e) {
            throw new RuntimeException(e);
        }
    }

decoder throws IndexOutofBoundsException

from readInt and readString in ByteBufDecoder

when reading from ByteBuf to decoder

I found the exception throws from here:

Netty 4.0.33 io.netty.buffer.AbstractByteBuf.java line 1178

private void checkReadableBytes0(int minimumReadableBytes) {
        ensureAccessible();
        if (readerIndex > writerIndex - minimumReadableBytes) {
            throw new IndexOutOfBoundsException(String.format(
                    "readerIndex(%d) + length(%d) exceeds writerIndex(%d): %s",
                    readerIndex, minimumReadableBytes, writerIndex, this));
        }
}
Caused by: java.lang.IndexOutOfBoundsException
	at io.netty.buffer.EmptyByteBuf.readUnsignedByte(EmptyByteBuf.java:445)
	at com.github.milenkovicm.avro.io.ByteBufDecoder.readInt(ByteBufDecoder.java:38)
	at com.github.milenkovicm.avro.io.ByteBufDecoder.readString(ByteBufDecoder.java:91)
	at org.apache.avro.io.ResolvingDecoder.readString(ResolvingDecoder.java:201)
	at org.apache.avro.generic.GenericDatumReader.readString(GenericDatumReader.java:430)
	at org.apache.avro.generic.GenericDatumReader.readString(GenericDatumReader.java:422)

avro schema:

{"namespace": "example.avro",
 "type": "record",
 "name": "User",
 "fields": [
     {"name": "name", "type": "string"},
     {"name": "favorite_number",  "type": ["int", "null"]},
     {"name": "favorite_color", "type": ["string", "null"]}
 ]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.