@Test public void metadataInitialization_eager() throws IOException { StorageObject object = newStorageObject(BUCKET_NAME, OBJECT_NAME); MockHttpTransport transport = mockTransport(jsonDataResponse(object)); List<HttpRequest> requests = new ArrayList<>(); Storage storage = new Storage(transport, JSON_FACTORY, requests::add); GoogleCloudStorageReadOptions options = GoogleCloudStorageReadOptions.builder().setFastFailOnNotFound(true).build(); GoogleCloudStorageReadChannel readChannel = createReadChannel(storage, options); assertThat(requests).hasSize(1); assertThat(readChannel.size()).isEqualTo(object.getSize().longValue()); assertThat(requests).hasSize(1); }
@Override public long size() throws IOException { throwIfNotOpen(); if (!metadataInitialized) { initMetadata(fetchInitialMetadata()); } return size; }
GoogleCloudStorageReadChannel implements SeekableByteChannel { @Override public long size() throws IOException { throwIfNotOpen(); if (!metadataInitialized) { initMetadata(fetchInitialMetadata()); } return size; } }
GoogleCloudStorageReadChannel implements SeekableByteChannel { @Override public long size() throws IOException { throwIfNotOpen(); if (!metadataInitialized) { initMetadata(fetchInitialMetadata()); } return size; } GoogleCloudStorageReadChannel(
      Storage gcs,
      String bucketName,
      String objectName,
      ApiErrorExtractor errorExtractor,
      ClientRequestHelper<StorageObject> requestHelper);  GoogleCloudStorageReadChannel(
      Storage gcs,
      String bucketName,
      String objectName,
      ApiErrorExtractor errorExtractor,
      ClientRequestHelper<StorageObject> requestHelper,
      @Nonnull GoogleCloudStorageReadOptions readOptions);  GoogleCloudStorageReadChannel(
      Storage gcs,
      StorageResourceId resourceId,
      ApiErrorExtractor errorExtractor,
      ClientRequestHelper<StorageObject> requestHelper,
      @Nonnull GoogleCloudStorageReadOptions readOptions); protected  GoogleCloudStorageReadChannel(
      String bucketName, String objectName, @Nonnull GoogleCloudStorageReadOptions readOptions); }
GoogleCloudStorageReadChannel implements SeekableByteChannel { @Override public long size() throws IOException { throwIfNotOpen(); if (!metadataInitialized) { initMetadata(fetchInitialMetadata()); } return size; } GoogleCloudStorageReadChannel(
      Storage gcs,
      String bucketName,
      String objectName,
      ApiErrorExtractor errorExtractor,
      ClientRequestHelper<StorageObject> requestHelper);  GoogleCloudStorageReadChannel(
      Storage gcs,
      String bucketName,
      String objectName,
      ApiErrorExtractor errorExtractor,
      ClientRequestHelper<StorageObject> requestHelper,
      @Nonnull GoogleCloudStorageReadOptions readOptions);  GoogleCloudStorageReadChannel(
      Storage gcs,
      StorageResourceId resourceId,
      ApiErrorExtractor errorExtractor,
      ClientRequestHelper<StorageObject> requestHelper,
      @Nonnull GoogleCloudStorageReadOptions readOptions); protected  GoogleCloudStorageReadChannel(
      String bucketName, String objectName, @Nonnull GoogleCloudStorageReadOptions readOptions); void setMaxRetries(int maxRetries); @Override int read(ByteBuffer buffer); @Override SeekableByteChannel truncate(long size); @Override int write(ByteBuffer src); @Override boolean isOpen(); @Override void close(); @Override long position(); @Override SeekableByteChannel position(long newPosition); @Override long size(); }
GoogleCloudStorageReadChannel implements SeekableByteChannel { @Override public long size() throws IOException { throwIfNotOpen(); if (!metadataInitialized) { initMetadata(fetchInitialMetadata()); } return size; } GoogleCloudStorageReadChannel(
      Storage gcs,
      String bucketName,
      String objectName,
      ApiErrorExtractor errorExtractor,
      ClientRequestHelper<StorageObject> requestHelper);  GoogleCloudStorageReadChannel(
      Storage gcs,
      String bucketName,
      String objectName,
      ApiErrorExtractor errorExtractor,
      ClientRequestHelper<StorageObject> requestHelper,
      @Nonnull GoogleCloudStorageReadOptions readOptions);  GoogleCloudStorageReadChannel(
      Storage gcs,
      StorageResourceId resourceId,
      ApiErrorExtractor errorExtractor,
      ClientRequestHelper<StorageObject> requestHelper,
      @Nonnull GoogleCloudStorageReadOptions readOptions); protected  GoogleCloudStorageReadChannel(
      String bucketName, String objectName, @Nonnull GoogleCloudStorageReadOptions readOptions); void setMaxRetries(int maxRetries); @Override int read(ByteBuffer buffer); @Override SeekableByteChannel truncate(long size); @Override int write(ByteBuffer src); @Override boolean isOpen(); @Override void close(); @Override long position(); @Override SeekableByteChannel position(long newPosition); @Override long size();  }