RFR 8196298 Add null Reader and Writer

Alan Bateman Alan.Bateman at oracle.com
Wed Feb 7 13:03:18 UTC 2018

On 03/02/2018 17:05, Patrick Reinhart wrote:
> :
> I reworked the tests and Writer implementation accordingly
> http://cr.openjdk.java.net/~reinhapa/reviews/8196298/webrev.01
Just catching up on this.

nullReader's javadoc suggests that mark(int) does not nothing but this 
seems to conflict with the Reader's javadoc where it is specified to 
throw IOE when mark is not supported.

I'm a bit uneasy with len==0 check in the read method. I realize this is 
trying to mirror InputStream.read and maybe some Reader implementations 
but it's not specified behavior. I think we have to re-examine the 
Reader spec to clarify this to avoid creating more inconsistencies.

Similarly in nullWriter() where it looks like the the len==0 checks is 
in unspecified territory. I think this will need clarifications to the 
Writer spec. One obvious inconsistency is to close the writer and call 
write("") and write("",  0, 0). The first will fail as the writer is 
closed, the second does not fail.

Another one is read(CharBuffer). Suppose CharBuffer cb has 0 bytes 
remaining; if I invoke nullReader().read(cb) then it looks like it will 
return 0 whereas the read(CharBuffer) method is specified to return -1.


More information about the core-libs-dev mailing list