-
Notifications
You must be signed in to change notification settings - Fork 85
Closed
Labels
api: storageIssues related to the googleapis/java-storage API.Issues related to the googleapis/java-storage API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.Important issue which blocks shipping the next release. Will be fixed prior to next release.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.
Description
Issue with com.google.cloud.storage.Storage#update(com.google.cloud.storage.BucketInfo, com.google.cloud.storage.Storage.BucketTargetOption...)
Expected behaviour:
update only fields that are specified in BucketInfo parameter.
Actual behaviour:
along the updated fields, removes lifecycle rules if they are not specified.
Example code:
val bucketId = "[...]"
val client = StorageOptions.getDefaultInstance.getService
val before = client.get(bucketId)
println(s"Before: ${before.getLifecycleRules.size()}")
val updateRequest = BucketInfo
.newBuilder(bucketId)
.setLabels(singletonMap("test", "test"))
.build
client.update(updateRequest)
val after = client.get(bucketId)
println(s"After: ${after.getLifecycleRules.size()}")Actual output (for bucket with 1 lifecycle rule):
Before: 1
After: 0I suspect that issue is located here:
java-storage/google-cloud-storage/src/main/java/com/google/cloud/storage/BucketInfo.java
Lines 1841 to 1869 in accf502
| Set<Rule> rules = new HashSet<>(); | |
| if (deleteRules != null) { | |
| rules.addAll( | |
| transform( | |
| deleteRules, | |
| new Function<DeleteRule, Rule>() { | |
| @Override | |
| public Rule apply(DeleteRule deleteRule) { | |
| return deleteRule.toPb(); | |
| } | |
| })); | |
| } | |
| if (lifecycleRules != null) { | |
| rules.addAll( | |
| transform( | |
| lifecycleRules, | |
| new Function<LifecycleRule, Rule>() { | |
| @Override | |
| public Rule apply(LifecycleRule lifecycleRule) { | |
| return lifecycleRule.toPb(); | |
| } | |
| })); | |
| } | |
| if (rules != null) { | |
| Lifecycle lifecycle = new Lifecycle(); | |
| lifecycle.setRule(ImmutableList.copyOf(rules)); | |
| bucketPb.setLifecycle(lifecycle); | |
| } |
Metadata
Metadata
Assignees
Labels
api: storageIssues related to the googleapis/java-storage API.Issues related to the googleapis/java-storage API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.Important issue which blocks shipping the next release. Will be fixed prior to next release.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.