Sitelet https://github.com/googleapis/java-storage/issues/694
Skip to content
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.

StorageBatch get IllegalStateException #694

Description

@lwshuo

I'm trying to delete in a batch and got IllegalStateException. I think I'm doing something wrong but can't tell what it is with the doc I can find. Thank you!

Java version: 11
storage version(s): google-cloud-storage 1.103.1

Code example

    Iterable<Blob> blobs =
        gcs.list(bucketName, Storage.BlobListOption.prefix(objectNamePrefix)).iterateAll();
    try {
      StorageBatch batch = gcs.batch();

      for (Blob blob : blobs) {
        batch
            .delete(blob.getBlobId())
            .notify(
                new BatchResult.Callback<Boolean, StorageException>() {
                  public void success(Boolean result) {}

                  public void error(StorageException exception) {
                    exception.printStackTrace();
                  }
                });
      }
      batch.submit();
    } catch (UnsupportedOperationException ex) {

    }

Stack trace

Caused by: java.lang.IllegalStateException: null
	at com.google.common.base.Preconditions.checkState(Preconditions.java:492) ~[guava-28.2-jre.jar!/:na]
	at com.google.api.client.util.Preconditions.checkState(Preconditions.java:79) ~[google-http-client-1.34.0.jar!/:1.34.0]
	at com.google.api.client.googleapis.batch.BatchRequest.execute(BatchRequest.java:233) ~[google-api-client-1.30.7.jar!/:1.30.7]
	at com.google.cloud.storage.spi.v1.HttpStorageRpc$DefaultRpcBatch.submit(HttpStorageRpc.java:201) ~[google-cloud-storage-1.103.1.jar!/:1.103.1]
	at com.google.cloud.storage.StorageBatch.submit(StorageBatch.java:149) ~[google-cloud-storage-1.103.1.jar!/:1.103.1]

Activity

  1. self-assigned this
    on Jan 28, 2021
  2. added
    status: investigatingThe issue is under investigation, which is determined to be non-trivial.
    type: questionRequest for information or clarification. Not an issue.
    and removed
    triage meI really want to be triaged.
    on Jan 28, 2021
  3. removed
    status: investigatingThe issue is under investigation, which is determined to be non-trivial.
    on May 21, 2021
  4. frankyn commented on May 21, 2021

    @frankyn
    Contributor

    Ben could you take a look at this issue? It fell between the cracks for me.

  5. added
    priority: p3Desirable enhancement or fix. May not be included in next release.
    on Jan 11, 2022
  6. BenWhitehead commented on Jul 14, 2022

    @BenWhitehead
    Collaborator

    Looks like this error happens when the batch is empty. Unfortunately, the validation didn't include this information. I've proposed googleapis/google-api-java-client#2109 in the BatchRequest to include this additional context in the error.

  7. BenWhitehead commented on Jul 15, 2022

    @BenWhitehead
    Collaborator

    No code change necessary in this repo. Waiting on next release of api-client to flow into the repo before closing this.

  8. BenWhitehead commented on Feb 6, 2023

    @BenWhitehead
    Collaborator

    Fixed via and released a while ago googleapis/google-api-java-client#2109

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the googleapis/java-storage API.priority: p3Desirable enhancement or fix. May not be included in next release.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions