Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.boon.primitive.CharBuf.toCharArray() returns data followed by unexpected characters #340

Open
har-ki opened this issue Oct 14, 2015 · 7 comments

Comments

@har-ki
Copy link

har-ki commented Oct 14, 2015

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.

@har-ki
Copy link
Author

har-ki commented Oct 14, 2015

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);

@RichardHightower
Copy link
Contributor

CharBuf is a quasi internal class.
If you found a good way to use it in your own project. Good job. :)

@har-ki
Copy link
Author

har-ki commented Oct 19, 2015

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 [email protected]
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
#340 (comment).

@KowBlack
Copy link

4000 bytes again... is it related to #338 ?

@har-ki
Copy link
Author

har-ki commented Oct 20, 2015

Ah yes! It seems to be the same issue.
On Mon, Oct 19, 2015 at 4:50 PM KowBlack [email protected] wrote:

4000 bytes again... is it related to #338
#338 ?


Reply to this email directly or view it on GitHub
#340 (comment).

@RichardHightower
Copy link
Contributor

Please send me a test case so I can reproduce it. I reread the issue and I think I understand it better now. :)

@KowBlack
Copy link

I have a test case in #338

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants