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

Added writeString(Reader, int) method to JsonGenerator as requested i… #309

Closed
wants to merge 1 commit into from

Conversation

terziele
Copy link

@terziele terziele commented Aug 8, 2016

Resolve #17 issue.
Well, at least I think so. :)

@cowtowncoder
Copy link
Member

I don't think it works... which is also why unit test(s) would absolutely be required here. :)

*/
public void writeString(Reader reader, int charLength) throws IOException {
if (reader == null) {
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an error probably ,not just bailing out.

}

if (charLength == -1) {
while (reader.read() != -1) ;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, what? If not known, quietly swallow content?!?!? And do that as inefficiently as possible, char by char, instead of skipping?

} else {
int readChars = reader.read(new char[charLength]);

if (readChars < charLength) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

,... and readers are entirely within their rights to return less.

@cowtowncoder
Copy link
Member

Uh no. This makes no sense as implementation, no unit test. What the hell.

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

Successfully merging this pull request may close these issues.

2 participants