GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Storage#update always removes all lifecycle rules if they are not specified · Issue #850 · googleapis/java-storage

This repository was archived by the owner on Sep 25, 2026. It is now read-only.
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

Storage#update always removes all lifecycle rules if they are not specified #850

Copy link
Copy link
Closed
#852
Closed
Storage#update always removes all lifecycle rules if they are not specified#850
#852
Copy link
Assignees
BenWhitehead
Labels
api: storageIssues related to the googleapis/java-storage API.priority: p1Important 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.

Description

@sisidra
sisidra
opened on May 27, 2021
Issue body actions

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: 0

I 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);
}

Activity

  1. product-auto-label
    added
    api: storageIssues related to the googleapis/java-storage API.
    on May 27, 2021
  2. BenWhitehead
    added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on May 27, 2021
  3. BenWhitehead commented on May 27, 2021

    @BenWhitehead
    BenWhitehead
    on May 27, 2021
    Collaborator
    More actions

    Thanks for reporting this, the fix is included in #852 and will go out in the next release.

  4. BenWhitehead
    self-assigned this
    on May 27, 2021
  5. BenWhitehead
    added
    priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.
    on May 27, 2021
  6. BenWhitehead
    closed this as completedin #852on Jun 1, 2021
  7. BenWhitehead
    added a commit that references this issue on Jun 1, 2021

    fix: update BucketInfo translation code to properly handle lifecycle …

    This issue will close once commit 3b1df1d is merged into the 'main' branch.
    3b1df1d
  8. gcf-merge-on-green
    added a commit that references this issue on Jun 1, 2021

    chore: release 1.115.0 (#834)

    0018bcb
  9. BenWhitehead
    added a commit that references this issue on Sep 28, 2021

    fix(1.113.14-sp): backport critical bug fixes (#993)

    This issue will close once commit 447d35d is merged into the 'main' branch.
    447d35d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @BenWhitehead
    BenWhitehead

Labels

api: storageIssues related to the googleapis/java-storage API.priority: p1Important 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.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.