Open har-ki opened 9 years ago
Another way to do it while avoiding the copy and preserving the performance is as follows:
JsonSerializer serializer = mapper.serializer(); CharBuf serialize = serializer.serialize(myObj); int length = serialize.length(); writer.write(serialize.readForRecycle(), 0 , length);
CharBuf is a quasi internal class. If you found a good way to use it in your own project. Good job. :)
As I mentioned in the issue notes, the issue manifests in objectMapper.writeValue(Writer dest, Object value) method because it uses CharBuf.
On Sun, Oct 18, 2015 at 10:57 PM Richard Hightower notifications@github.com wrote:
CharBuf is a quasi internal class. If you found a good way to use it in your own project. Good job. :)
— Reply to this email directly or view it on GitHub https://github.com/boonproject/boon/issues/340#issuecomment-149109680.
4000 bytes again... is it related to https://github.com/boonproject/boon/issues/338 ?
Ah yes! It seems to be the same issue. On Mon, Oct 19, 2015 at 4:50 PM KowBlack notifications@github.com wrote:
4000 bytes again... is it related to #338 https://github.com/boonproject/boon/issues/338 ?
— Reply to this email directly or view it on GitHub https://github.com/boonproject/boon/issues/340#issuecomment-149379041.
Please send me a test case so I can reproduce it. I reread the issue and I think I understand it better now. :)
I have a test case in https://github.com/boonproject/boon/issues/338
Unlike the toString() method, the toCharArray() method does not take into account the current location. It returns the entire buffer which is 4000 chars long.
The issue manifests in objectMapper.writeValue(Writer dest, Object value) method.
Workaround is:
JsonSerializer serializer = mapper.serializer(); CharBuf serialize = serializer.serialize(myObj); writer.write(serialize.toString());
But this results in a copy and may affect performance.