Fix issue with UTF-8 surrogate pair decoding by pjfanning · Pull Request #608 · FasterXML/jackson-dataformats-text (original) (raw)

Choose a reason for hiding this comment

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

Isn't this illegal thing to do? read() method must return at least 1 char if asked for 1 or more, or return -1 to indicate end-of-stream, or throw Exception. 0 is only ever allowed to be returned for reads with len of 0:

https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/Reader.html#read(char%5B%5D,int,int)

If len is zero, then no characters are read and 0 is returned; otherwise, there is an attempt to read at least one character. If no character is available because the stream is at its end, the value -1 is returned; otherwise, at least one character is read and stored into cbuf.