Closed
Description
If you write >256 shared keys, the output stream contains -1 byte even though it's not the end of the document. This is a problem for us as we rely on the -1 marker to separate docs from a binary stream without the need to parse them.
Here is a failing junit reproduction:
@Test
public void testJacksonEndOfDocByte() throws Exception {
final String[] currentField = new String[1];
OutputStream outputStream = new OutputStream() {
@Override
public void write(int b) throws IOException {
if ((byte) b == -1) {
fail("got end of doc marker while writing " + currentField[0]);
}
}
};
SmileGenerator generator = new SmileFactory().createGenerator(outputStream);
generator.writeStartObject();
generator.writeFieldName("a");
generator.writeStartObject();
for (int i=0; i < 300; i++) {
currentField[0] = "f_"+i;
generator.writeNumberField(currentField[0], i);
generator.flush();
}
currentField[0] = "";
generator.writeEndObject();
generator.writeFieldName("b");
generator.writeStartObject();
for (int i=0; i < 300; i++) {
currentField[0] = "f_"+i;
generator.writeNumberField(currentField[0], i);
generator.flush();
}
currentField[0] = "";
generator.writeEndObject();
generator.writeEndObject();
}
I believe the problem lies in this line, which writes an un escaped byte as the second parameter:
Metadata
Metadata
Assignees
Labels
No labels