@Override
  public void close() throws IOException {
    if (closed) {
      return;
    }
    closed = true;

    blockData = null;
    reader.close();
    reader = null;
    remoteObject = null;
    fpos.invalidate();
    try {
      client.close();
    } finally {
      streamStatistics.close();
    }
    client = null;
  }
@Test
  public void testClose() throws Exception {
    S3ARemoteInputStream inputStream =
        S3APrefetchFakes.createS3InMemoryInputStream(futurePool, "bucket",
            "key", 9);
    testCloseHelper(inputStream, 9);

    inputStream =
        S3APrefetchFakes.createS3CachingInputStream(futurePool, "bucket", "key",
            9, 5, 3);
    testCloseHelper(inputStream, 5);
  }