GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(gax): add globalTimeout settings field to ResumableUploadCallSettings by whowes · Pull Request #14253 · googleapis/google-cloud-java

feat(gax): add globalTimeout settings field to ResumableUploadCallSettings #14253

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.

Sign up for GitHub

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

Merged
whowes merged 1 commit into main from whowes/resumable-upload-settings
Sep 14, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

feat(gax): add globalTimeout settings field to ResumableUploadCallSettings #14253

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
b1a0571
feat(gax): add globalTimeout settings field to ResumableUploadCallSet…
whowes Sep 3, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

Some comments aren't visible on the classic Files Changed page.

There are no files selected for viewing

40 changes: 36 additions & 4 deletions 40 ...m-java/gax-java/gax/src/main/java/com/google/api/gax/rpc/ResumableUploadCallSettings.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,49 @@

import com.google.api.core.BetaApi;
import com.google.auto.value.AutoValue;
import com.google.common.base.Preconditions;
import java.time.Duration;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/**
* A settings class to configure a {@link ResumableUploadCallable} for executing resumable uploads.
* Encapsulates protocol options such as payload chunk size.
* Encapsulates protocol options such as payload chunk size and global upload timeout.
*/
@BetaApi
@AutoValue
@NullMarked
public abstract class ResumableUploadCallSettings {
private static final int DEFAULT_CHUNK_SIZE = 8 * 1024 * 1024; // 8 MB

/** Returns the configured chunk size in bytes (defaults to 8 MB / 8,388,608 bytes). */
public abstract int getChunkSize();

/**
* Returns the global upload timeout governing the entire upload duration, or {@code null} if
* disabled.
*/
public abstract @Nullable Duration getGlobalTimeout();
Comment thread

@blakeli0 blakeli0 Sep 10, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind pointing me to the requirements of this timeout?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@whowes whowes Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up with this offline.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

/**
* Merges another {@code ResumableUploadCallSettings} instance with this one. Fields set in {@code
* other} override fields in this instance.
*
* @param other settings to overlay; may be {@code null}
* @return a new, resolved {@code ResumableUploadCallSettings} instance
*/
public ResumableUploadCallSettings merge(ResumableUploadCallSettings other) {
public ResumableUploadCallSettings merge(@Nullable ResumableUploadCallSettings other) {
if (other == null) {
return this;
}
return toBuilder().setChunkSize(other.getChunkSize()).build();
Builder builder = toBuilder();
if (other.getChunkSize() > 0) {
builder.setChunkSize(other.getChunkSize());
}
if (other.getGlobalTimeout() != null) {
builder.setGlobalTimeout(other.getGlobalTimeout());
}
return builder.build();
}

public abstract Builder toBuilder();
Expand All @@ -71,6 +89,20 @@ public abstract static class Builder {

public abstract int getChunkSize();

public abstract ResumableUploadCallSettings build();
public abstract Builder setGlobalTimeout(@Nullable Duration globalTimeout);

public abstract @Nullable Duration getGlobalTimeout();

abstract ResumableUploadCallSettings autoBuild();

public ResumableUploadCallSettings build() {
Preconditions.checkArgument(getChunkSize() > 0, "chunkSize must be > 0");
if (getGlobalTimeout() != null) {
Preconditions.checkArgument(
!getGlobalTimeout().isNegative() && !getGlobalTimeout().isZero(),
"globalTimeout must be positive");
}
return autoBuild();
}
}
}
67 changes: 54 additions & 13 deletions 67 ...va/gax-java/gax/src/test/java/com/google/api/gax/rpc/ResumableUploadCallSettingsTest.java
Show comments Show annotations
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -31,47 +31,88 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.time.Duration;
import org.junit.jupiter.api.Test;

public class ResumableUploadCallSettingsTest {

@Test
public void testDefaultChunkSizeInBuilder() {
ResumableUploadCallSettings settings = ResumableUploadCallSettings.newBuilder().build();
public void testCustomSettingsAndToBuilder() {
ResumableUploadCallSettings settings =
ResumableUploadCallSettings.newBuilder()
.setChunkSize(16 * 1024 * 1024)
.setGlobalTimeout(Duration.ofMinutes(15))
.build();

assertEquals(16 * 1024 * 1024, settings.getChunkSize());
assertEquals(Duration.ofMinutes(15), settings.getGlobalTimeout());
assertEquals(settings, settings.toBuilder().build());
}

assertEquals(8 * 1024 * 1024, settings.getChunkSize());
@Test
public void testInvalidChunkSize_throwsIllegalArgumentException() {
assertThrows(

Check warning on line 56 in sdk-platform-java/gax-java/gax/src/test/java/com/google/api/gax/rpc/ResumableUploadCallSettingsTest.java

View check run for this annotation

SonarQubeCloud / [gapic-generator-java-root] SonarCloud Code Analysis

Refactor the code of the lambda to have only one invocation possibly throwing a runtime exception.

See more on https://sonarcloud.io/project/issues?id=googleapis_google-cloud-java_showcase&issues=AaBumadI4VFARgn-a4gc&open=AaBumadI4VFARgn-a4gc&pullRequest=14253
IllegalArgumentException.class,
() -> ResumableUploadCallSettings.newBuilder().setChunkSize(0).build());
assertThrows(

Check warning on line 59 in sdk-platform-java/gax-java/gax/src/test/java/com/google/api/gax/rpc/ResumableUploadCallSettingsTest.java

View check run for this annotation

SonarQubeCloud / [gapic-generator-java-root] SonarCloud Code Analysis

Refactor the code of the lambda to have only one invocation possibly throwing a runtime exception.

See more on https://sonarcloud.io/project/issues?id=googleapis_google-cloud-java_showcase&issues=AaBumadI4VFARgn-a4gd&open=AaBumadI4VFARgn-a4gd&pullRequest=14253
IllegalArgumentException.class,
() -> ResumableUploadCallSettings.newBuilder().setChunkSize(-1).build());
}

@Test
public void testInvalidGlobalTimeout_throwsIllegalArgumentException() {
assertThrows(

Check warning on line 66 in sdk-platform-java/gax-java/gax/src/test/java/com/google/api/gax/rpc/ResumableUploadCallSettingsTest.java

View check run for this annotation

SonarQubeCloud / [gapic-generator-java-root] SonarCloud Code Analysis

Refactor the code of the lambda to have only one invocation possibly throwing a runtime exception.

See more on https://sonarcloud.io/project/issues?id=googleapis_google-cloud-java_showcase&issues=AaBumadI4VFARgn-a4ge&open=AaBumadI4VFARgn-a4ge&pullRequest=14253
IllegalArgumentException.class,
() -> ResumableUploadCallSettings.newBuilder().setGlobalTimeout(Duration.ZERO).build());
assertThrows(

Check warning on line 69 in sdk-platform-java/gax-java/gax/src/test/java/com/google/api/gax/rpc/ResumableUploadCallSettingsTest.java

View check run for this annotation

SonarQubeCloud / [gapic-generator-java-root] SonarCloud Code Analysis

Refactor the code of the lambda to have only one invocation possibly throwing a runtime exception.

See more on https://sonarcloud.io/project/issues?id=googleapis_google-cloud-java_showcase&issues=AaBumadI4VFARgn-a4gf&open=AaBumadI4VFARgn-a4gf&pullRequest=14253
IllegalArgumentException.class,
() ->
ResumableUploadCallSettings.newBuilder()
.setGlobalTimeout(Duration.ofSeconds(-5))
.build());
}

@Test
public void testCustomInitialization() {
public void testMerge_nullSettings_returnsSameInstance() {
ResumableUploadCallSettings settings =
ResumableUploadCallSettings.newBuilder().setChunkSize(16 * 1024 * 1024).build();
ResumableUploadCallSettings.newBuilder().setChunkSize(4 * 1024 * 1024).build();

assertEquals(16 * 1024 * 1024, settings.getChunkSize());
assertSame(settings, settings.merge(null));
}

@Test
public void testMerge_NullSettings() {
public void testMerge_overridesChunkSizeAndGlobalTimeout() {
ResumableUploadCallSettings stubSettings =
ResumableUploadCallSettings.newBuilder().setChunkSize(4 * 1024 * 1024).build();
ResumableUploadCallSettings.newBuilder()
.setChunkSize(4 * 1024 * 1024)
.setGlobalTimeout(Duration.ofMinutes(10))
.build();

ResumableUploadCallSettings perRequestSettings =
ResumableUploadCallSettings.newBuilder()
.setChunkSize(32 * 1024 * 1024)
.setGlobalTimeout(Duration.ofMinutes(30))
.build();

ResumableUploadCallSettings merged = stubSettings.merge(null);
ResumableUploadCallSettings merged = stubSettings.merge(perRequestSettings);

assertSame(stubSettings, merged);
assertEquals(32 * 1024 * 1024, merged.getChunkSize());
assertEquals(Duration.ofMinutes(30), merged.getGlobalTimeout());
}

@Test
public void testMerge_SettingsOverrides() {
public void testMerge_nullGlobalTimeoutDoesNotOverride() {
ResumableUploadCallSettings stubSettings =
ResumableUploadCallSettings.newBuilder().setChunkSize(4 * 1024 * 1024).build();
ResumableUploadCallSettings.newBuilder().setGlobalTimeout(Duration.ofMinutes(10)).build();

ResumableUploadCallSettings perRequestSettings =
ResumableUploadCallSettings.newBuilder().setChunkSize(32 * 1024 * 1024).build();

ResumableUploadCallSettings merged = stubSettings.merge(perRequestSettings);

// Chunk size overridden by Tier-1 per-request settings
assertEquals(32 * 1024 * 1024, merged.getChunkSize());
assertEquals(Duration.ofMinutes(10), merged.getGlobalTimeout());
}
}
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.