Skip to content

Commit f31a95a

Browse files
authored
fix: make DecodeMode.DIRECT the deafult (#3280)
DecodeMode.DIRECT should be the default mode for decoding rows.
1 parent b44104f commit f31a95a

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,7 @@ public static class Builder
741741
extends ServiceOptions.Builder<Spanner, SpannerOptions, SpannerOptions.Builder> {
742742
static final int DEFAULT_PREFETCH_CHUNKS = 4;
743743
static final QueryOptions DEFAULT_QUERY_OPTIONS = QueryOptions.getDefaultInstance();
744-
// TODO: Set the default to DecodeMode.DIRECT before merging to keep the current default.
745-
// It is currently set to LAZY_PER_COL so it is used in all tests.
746-
static final DecodeMode DEFAULT_DECODE_MODE = DecodeMode.LAZY_PER_COL;
744+
static final DecodeMode DEFAULT_DECODE_MODE = DecodeMode.DIRECT;
747745
static final RetrySettings DEFAULT_ADMIN_REQUESTS_LIMIT_EXCEEDED_RETRY_SETTINGS =
748746
RetrySettings.newBuilder()
749747
.setInitialRetryDelay(Duration.ofSeconds(5L))

google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java

+11-6
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,21 @@ public static void resetLogging() {
104104

105105
@Test
106106
public void defaultBuilder() {
107-
// We need to set the project id since in test environment we cannot obtain a default project
108-
// id.
109-
SpannerOptions options = SpannerOptions.newBuilder().setProjectId("test-project").build();
107+
// We need to set the project id and credentials since in test environments we cannot guarantee
108+
// that a default project id and credentials are available.
109+
SpannerOptions options =
110+
SpannerOptions.newBuilder()
111+
.setProjectId("test-project")
112+
.setCredentials(NoCredentials.getInstance())
113+
.build();
110114
if (Strings.isNullOrEmpty(System.getenv("SPANNER_EMULATOR_HOST"))) {
111-
assertThat(options.getHost()).isEqualTo("https://spanner.googleapis.com");
115+
assertEquals("https://spanner.googleapis.com", options.getHost());
112116
} else {
113-
assertThat(options.getHost()).isEqualTo("https://" + System.getenv("SPANNER_EMULATOR_HOST"));
117+
assertEquals("https://" + System.getenv("SPANNER_EMULATOR_HOST"), options.getHost());
114118
}
115-
assertThat(options.getPrefetchChunks()).isEqualTo(4);
119+
assertEquals(4, options.getPrefetchChunks());
116120
assertNull(options.getSessionLabels());
121+
assertEquals(DecodeMode.DIRECT, options.getDecodeMode());
117122
}
118123

119124
@Test

0 commit comments

Comments
 (0)