{
// but should not occur if configured otherwise
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationConfig.Feature.FLUSH_AFTER_WRITE_VALUE, false);
StringWriter sw = new StringWriter();
JsonGenerator jgen = mapper.getJsonFactory().createJsonGenerator(sw);
mapper.writeValue(jgen, Integer.valueOf(13));
// no flushing now:
assertEquals("", sw.toString());
// except when actually flushing
jgen.flush();
assertEquals("13", sw.toString());
jgen.close();
// Also, same should happen with ObjectWriter
sw = new StringWriter();
jgen = mapper.getJsonFactory().createJsonGenerator(sw);
ObjectWriter ow = mapper.writer();
ow.writeValue(jgen, Integer.valueOf(99));
assertEquals("", sw.toString());
// except when actually flushing
jgen.flush();
assertEquals("99", sw.toString());
jgen.close();
}