From 8314bdf5c719cc732fc9c2a1d655ebb8060fe252 Mon Sep 17 00:00:00 2001 From: BenWhitehead Date: Thu, 14 Jul 2022 11:46:29 -0400 Subject: [PATCH] fix: add error description to batch emptiness validation 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 https://github.com/googleapis/java-storage/issues/694 --- .../com/google/api/client/googleapis/batch/BatchRequest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-api-client/src/main/java/com/google/api/client/googleapis/batch/BatchRequest.java b/google-api-client/src/main/java/com/google/api/client/googleapis/batch/BatchRequest.java index 8424be592..5e57ac765 100644 --- a/google-api-client/src/main/java/com/google/api/client/googleapis/batch/BatchRequest.java +++ b/google-api-client/src/main/java/com/google/api/client/googleapis/batch/BatchRequest.java @@ -228,7 +228,7 @@ public int size() { */ public void execute() throws IOException { boolean retryAllowed; - Preconditions.checkState(!requestInfos.isEmpty()); + Preconditions.checkState(!requestInfos.isEmpty(), "Batch is empty"); // Log a warning if the user is using the global batch endpoint. In the future, we can turn this // into a preconditions check.