}
}
@Test
public void shouldNotReleaseBufferWhenBufToJson() throws Exception {
ByteBuf content = ReferenceCountUtil.releaseLater(
Unpooled.copiedBuffer("{}", CharsetUtil.UTF_8));
JsonObject decoded = converter.byteBufToJsonObject(content);
assertEquals(1, content.refCnt());
content = ReferenceCountUtil.releaseLater(
Unpooled.copiedBuffer("thisIsNotJson", CharsetUtil.UTF_8));
try {
decoded = converter.byteBufToJsonObject(content);
fail();
} catch (JsonParseException e) {
//NO-OP, exception expected
} catch (Exception e) {
fail(e.toString());
} finally {
assertEquals(1, content.refCnt());
}
}