fix: update apimaxrequestbytes to be the accurate 20mb (#3099) · googleapis/java-bigquerystorage@00b465b

File tree

3 files changed

lines changed

  • google-cloud-bigquerystorage/src

    • main/java/com/google/cloud/bigquery/storage/v1

    • test/java/com/google/cloud/bigquery/storage/v1

3 files changed

lines changed

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) {

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

/**

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 =