Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StorageBatch get IllegalStateException #694

Closed
lwshuo opened this issue Jan 27, 2021 · 4 comments
Closed

StorageBatch get IllegalStateException #694

lwshuo opened this issue Jan 27, 2021 · 4 comments
Assignees
Labels
api: storage Issues related to the googleapis/java-storage API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue.

Comments

@lwshuo
Copy link

lwshuo commented Jan 27, 2021

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]
@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/java-storage API. label Jan 27, 2021
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Jan 28, 2021
@frankyn frankyn self-assigned this Jan 28, 2021
@frankyn frankyn added status: investigating The issue is under investigation, which is determined to be non-trivial. type: question Request for information or clarification. Not an issue. and removed triage me I really want to be triaged. labels Jan 28, 2021
@frankyn frankyn removed the status: investigating The issue is under investigation, which is determined to be non-trivial. label May 21, 2021
@frankyn frankyn assigned BenWhitehead and unassigned frankyn May 21, 2021
@frankyn
Copy link
Member

frankyn commented May 21, 2021

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

@BenWhitehead BenWhitehead added the priority: p3 Desirable enhancement or fix. May not be included in next release. label Jan 11, 2022
BenWhitehead added a commit to googleapis/google-api-java-client that referenced this issue Jul 14, 2022
When invoking BatchRequest#execute(), we ensure the batch contains at
least one request to process. Previously this check, did not provide any
error message. Now, if the check fails "Batch is empty" will be the
message of the resulting exception.

Related to googleapis/java-storage#694
@BenWhitehead
Copy link
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.

BenWhitehead added a commit to googleapis/google-api-java-client that referenced this issue Jul 15, 2022
When invoking BatchRequest#execute(), we ensure the batch contains at
least one request to process. Previously this check, did not provide any
error message. Now, if the check fails "Batch is empty" will be the
message of the resulting exception.

Related to googleapis/java-storage#694
@BenWhitehead
Copy link
Collaborator

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

blakeli0 pushed a commit to googleapis/google-api-java-client that referenced this issue Dec 16, 2022
When invoking BatchRequest#execute(), we ensure the batch contains at
least one request to process. Previously this check, did not provide any
error message. Now, if the check fails "Batch is empty" will be the
message of the resulting exception.

Related to googleapis/java-storage#694
blakeli0 pushed a commit to googleapis/google-api-java-client that referenced this issue Dec 16, 2022
When invoking BatchRequest#execute(), we ensure the batch contains at
least one request to process. Previously this check, did not provide any
error message. Now, if the check fails "Batch is empty" will be the
message of the resulting exception.

Related to googleapis/java-storage#694
@BenWhitehead
Copy link
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
Labels
api: storage Issues related to the googleapis/java-storage API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

4 participants