diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/GapicUnbufferedReadableByteChannel.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/GapicUnbufferedReadableByteChannel.java index 67891dbc28..24246d73f9 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/GapicUnbufferedReadableByteChannel.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/GapicUnbufferedReadableByteChannel.java @@ -144,8 +144,10 @@ public long read(ByteBuffer[] dsts, int offset, int length) throws IOException { if (hasRemaining(bfl)) { leftovers = bfl; } else { - stream.close(); - stream = null; + if(stream != null) { + stream.close(); + stream = null; + } } } else { complete = true; diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcStorageImpl.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcStorageImpl.java index 67292ebc1a..2b86c82fba 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcStorageImpl.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcStorageImpl.java @@ -111,7 +111,6 @@ import java.util.stream.StreamSupport; import com.google.storage.v2.stub.GrpcStorageCallableFactory; -import com.google.storage.v2.stub.GrpcStorageStub; import io.grpc.*; import io.grpc.protobuf.ProtoUtils; import io.grpc.protobuf.lite.ProtoLiteUtils;