Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Operations on Buckets should use Storage.*Option types #702

Copy link
Copy link
@dimo414

Description

@dimo414
Issue body actions

Some of the static classes in Storage, such as BlobTargetOption which is used by Storage.create(), are also being erroneously used in Bucket. This is problematic because Bucket keys of of path Strings, not BlobInfo instances, and therefore isn't able to extract information like the blob's generation, causing a line like this:

bucket.create(file, data, null, BlobTargetOption.generationMatch());

to fail:

 java.lang.IllegalArgumentException: Option ifGenerationMatch is missing a value
     at com.google.common.base.Preconditions.checkArgument(Preconditions.java:122)
     at com.google.gcloud.storage.StorageImpl.addToOptionMap(StorageImpl.java:651)
     at com.google.gcloud.storage.StorageImpl.addToOptionMap(StorageImpl.java:643)
     at com.google.gcloud.storage.StorageImpl.optionMap(StorageImpl.java:681)
     at com.google.gcloud.storage.StorageImpl.optionMap(StorageImpl.java:660)
     at com.google.gcloud.storage.StorageImpl.optionMap(StorageImpl.java:695)
     at com.google.gcloud.storage.StorageImpl.optionMap(StorageImpl.java:703)
     at com.google.gcloud.storage.StorageImpl.create(StorageImpl.java:140)
     at com.google.gcloud.storage.StorageImpl.create(StorageImpl.java:129)
     at com.google.gcloud.storage.Bucket.create(Bucket.java:360)

And there is no way in Storage.BlobTargetOption to actually specify a generation.

I don't think Bucket should have any dependency on the Storage.*Option types. There's clearly a good amount of overlap, but I don't think that's a good enough reason for them to share these types. Even where they behave the same it's confusing for the caller.

They could extend from a shared parent if we wanted, but that should be an implementation detail.

I can put together a patch to remove the dependencies on Storage.*Option from Bucket if that's desired.

Metadata

Metadata

Labels

api: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.