diff --git a/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/SeekableByteChannelPrefetcher.java b/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/SeekableByteChannelPrefetcher.java index dbdd4e5a..41632f8c 100644 --- a/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/SeekableByteChannelPrefetcher.java +++ b/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/SeekableByteChannelPrefetcher.java @@ -357,8 +357,10 @@ public ByteBuffer fetch(long position) throws InterruptedException, ExecutionExc nbMiss++; ensureFetching(blockIndex); candidate = fetching; - buf = candidate.getBuf(); - full.add(candidate); + if (candidate != null) { + buf = candidate.getBuf(); + full.add(candidate); + } fetching = null; ensureFetching(blockIndex + 1); return buf;