Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.

Commit 00b465b

Browse files
fix: update apimaxrequestbytes to be the accurate 20mb (#3099)
* Update ApiMaxRequestBytes to be the accurate 20MB * Fix test * chore: generate libraries at Mon Oct 6 18:46:51 UTC 2025 * Add back getApiMaxRequestBytes on StreamWriter. --------- Co-authored-by: cloud-java-bot <cloud-java-bot@google.com>
1 parent b9fad83 commit 00b465b

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ConnectionWorker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public static Boolean isDefaultStreamName(String streamName) {
271271

272272
/** The maximum size of one request. Defined by the API. */
273273
public static long getApiMaxRequestBytes() {
274-
return 20L * 1000L * 1000L; // 20 megabytes (https://en.wikipedia.org/wiki/Megabyte)
274+
return 20L * (1L << 20); // 20 megabytes (https://en.wikipedia.org/wiki/Megabyte)
275275
}
276276

277277
static String extractProjectName(String streamName) {

google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/StreamWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public class StreamWriter implements AutoCloseable {
141141

142142
/** The maximum size of one request. Defined by the API. */
143143
public static long getApiMaxRequestBytes() {
144-
return 10L * 1000L * 1000L; // 10 megabytes (https://en.wikipedia.org/wiki/Megabyte)
144+
return ConnectionWorker.getApiMaxRequestBytes();
145145
}
146146

147147
/**

google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/StreamWriterTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,8 @@ public void testMessageTooLarge() throws Exception {
14081408
StreamWriter writer = getTestStreamWriter();
14091409

14101410
// There is an oppotunity to allow 20MB requests.
1411-
String oversized = Strings.repeat("a", (int) (StreamWriter.getApiMaxRequestBytes() * 2 + 1));
1411+
String oversized =
1412+
Strings.repeat("a", (int) (ConnectionWorker.getApiMaxRequestBytes() * 2 + 1));
14121413
ApiFuture<AppendRowsResponse> appendFuture1 = sendTestMessage(writer, new String[] {oversized});
14131414
assertTrue(appendFuture1.isDone());
14141415
StatusRuntimeException actualError =

0 commit comments

Comments
 (0)