in src/main/java/org/apache/commons/io/input/UnsynchronizedBufferedInputStream.java [264:290]
public int read() throws IOException {
// Use local refs since buf and in may be invalidated by an
// unsynchronized close()
byte[] localBuf = buffer;
final InputStream localIn = inputStream;
if (localBuf == null || localIn == null) {
throw new IOException("Stream is closed");
}
/* Are there buffered bytes available? */
if (pos >= count && fillBuffer(localIn, localBuf) == IOUtils.EOF) {
return IOUtils.EOF; /* no, fill buffer */
}
// localBuf may have been invalidated by fillbuf
if (localBuf != buffer) {
localBuf = buffer;
if (localBuf == null) {
throw new IOException("Stream is closed");
}
}
/* Did filling the buffer fail with -1 (EOF)? */
if (count - pos > 0) {
return localBuf[pos++] & 0xFF;
}
return IOUtils.EOF;
}