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

Blob.listAcls() fails after writing the contents #2550

Copy link
Copy link

Description

@TheIndifferent
Issue body actions

Using Blob.listAcls() works on first invocation after the blob creation, but fails on second invocation after Blob.writer() was used to write the contents. To be able to use it, have to request Service for a new Blob instance without using BlobId of existing instnace. Please see the following reproducer code:

import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;

import com.google.cloud.WriteChannel;
import com.google.cloud.storage.Acl;
import com.google.cloud.storage.Blob;
import com.google.cloud.storage.BlobInfo;
import com.google.cloud.storage.Bucket;
import com.google.cloud.storage.BucketInfo;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageOptions;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import org.testng.annotations.Test;

public class GcsAclReproducerTest {

  @Test
  public void test() throws Exception {
    final String inputBucketName = UUID.randomUUID().toString();
    final String inputBlobName = UUID.randomUUID().toString();
    final Storage storageService = StorageOptions.getDefaultInstance().getService();
    final Bucket bucket = storageService.create(BucketInfo.newBuilder(inputBucketName).build());

    final Blob blob
        = storageService.create(BlobInfo.newBuilder(inputBucketName, inputBlobName).build());

    final List<Acl> acls1 = blob.listAcls();
    assertNotNull(acls1);
    assertFalse(acls1.isEmpty());

    try (final WriteChannel writer = blob.writer()) {
      final byte[] contents = new byte[1024 * 1024];
      new Random().nextBytes(contents);
      writer.write(ByteBuffer.wrap(contents));
    }

    final List<Acl> acls2 = blob.listAcls();
    assertNotNull(acls2);
    assertFalse(acls2.isEmpty());
  }
}
Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in 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.

Type

No type
No fields configured for issues without a 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.