Git Product home page Git Product logo

avropatch's People

Contributors

frankwis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

dguenms

avropatch's Issues

ArrayIndexOutOfBoundsException on different order of method calls to PatchMapper.builder()

Order of method calls to PatchMapper.builder() impacts deserialization:

PatchMapper serializer = PatchMapper.builder()
                .withType(Bimmel.class)
                .with(PatchMapper.arrayBuilder()
                        .withAvroPrimitives()
                        .withCustomTypes()
                        .build())
                .nullable()
                .withAvroPrimitives()
                .build();

PatchMapper deserializer = PatchMapper.builder()
                .withType(Bimmel.class)
                .with(PatchMapper.arrayBuilder()
                        .withCustomTypes()
                        .withAvroPrimitives()
                        .build())
                .nullable()
                .withAvroPrimitives()
                .build();

byte[] bytes = serializer.toBytes(patch);
assertThat(patch, is(equalTo(deserializer.toPatch(bytes))));
java.lang.ArrayIndexOutOfBoundsException: -27

	at org.apache.avro.io.parsing.Symbol$Alternative.getSymbol(Symbol.java:416)
	at org.apache.avro.io.ResolvingDecoder.doAction(ResolvingDecoder.java:290)
	at org.apache.avro.io.parsing.Parser.advance(Parser.java:88)
	at org.apache.avro.io.ResolvingDecoder.readIndex(ResolvingDecoder.java:267)
	at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:178)
	at org.apache.avro.reflect.ReflectDatumReader.readCollection(ReflectDatumReader.java:219)
	at org.apache.avro.reflect.ReflectDatumReader.readArray(ReflectDatumReader.java:137)
	at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:176)
	at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:152)
	at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:178)
	at org.apache.avro.reflect.ReflectDatumReader.readField(ReflectDatumReader.java:302)
	at org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:230)
	at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:174)
	at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:152)
	at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:178)
	at org.apache.avro.reflect.ReflectDatumReader.readCollection(ReflectDatumReader.java:219)
	at org.apache.avro.reflect.ReflectDatumReader.readArray(ReflectDatumReader.java:137)
	at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:176)
	at org.apache.avro.reflect.ReflectDatumReader.readField(ReflectDatumReader.java:302)
	at org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:230)
	at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:174)
	at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:152)
	at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:144)
	at io.datanerds.avropatch.serialization.PatchMapper.toPatch(PatchMapper.java:46)
	at io.datanerds.avropatch.serialization.PatchMapperTest.unionTest(PatchMapperTest.java:111)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

It looks like the order within Avro's schema union is crucial for resolving the types. Need to be deterministic on creation of the union list (e.g. alphabetical order).

Add versioning to schema

While working on this library the Avro schema may evolve. We should track the changes and version them.

Add some more meta information as first-class citizen

Currently avropatch supports headers and the change set out of the box. Let's add some more items as first-class citizens to the Patch POJO:

  • the timestamp to specify when the PATCH request was made
  • a resource representing the object to be updated by PATCH call
  • version Let's start versioning avropatch

Path::parse vs Path::of

Handling of parse and of is confusing since both take string arguments, but behave differently:

Path.of("/com")

results in

io.datanerds.avropatch.exception.InvalidReferenceTokenException: /com is not a valid JSON path

Add convenience accessor methods to `Patch`

We would like to have some convenience accessor methods for the Patchclass.

  • Currently, accessing and iterating over the operations is done via Patch#getOperations(). Let's add some methods to access them directly (e.g. Patch#size(), Patch#stream(), Patch#getOperation(int index) etc.)
  • Patch#getHeader(String name) would ease accessing a specific header, because right now, there's an indirection as well.
  • Since headers are not typed it would be nice to have a method to access a header with implicit casting

Create factory methods for Patch

Since we have so many versions of the constructor now, given 3 arguments it would be a good idea to use a builder or factory methods instead.

Only one assertion per test

In general there should be only one assertion per test method to avoid hiding further assertion failures after the first failing assertion which effectively may hide the real severity of the problem.

See http://blog.jayfields.com/2007/06/testing-one-assertion-per-test.html

Also reoccurring words in several test methods are a sign that the tests should be grouped together, i.e. with @Enclosed. Since that feature is still experimental let's discuss what we want to do.

(See comments for PR #14 )

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.