franslundberg/binson-java

Probably, the bug when generating nested empty objects: {"":{"":{"":{}}}}

ppmag opened this issue · 3 comments

ppmag commented

Pls try next code:

byte[] b = new Binson()
                         .put("", new Binson()
                                 .put("", new Binson())
                                        .put("", new Binson()))
                  .toBytes();

System.out.println("len: " + b.length + ", " + hex(b));

Result:

len: 10, "40140040140040414141"

When looking on above hexdump, it's easy to see innermost put() was skipped.

Needs to be verified. Could be a bug!

Labelled as "bug" for now since it is a potential actual bug.

This is not a bug. The problem is in the test code. Look at the parenthesis carefully! The empty Binson object is added twice with the same field name (""). The issue author should have written code that ends with "))))". Now it ends with ")))". Tricky to see.