From f31a95ab105407305e988e86c8f7b0d8654995e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Olav=20L=C3=B8ite?= Date: Mon, 19 Aug 2024 10:48:40 +0200 Subject: [PATCH] fix: make DecodeMode.DIRECT the deafult (#3280) DecodeMode.DIRECT should be the default mode for decoding rows. --- .../google/cloud/spanner/SpannerOptions.java | 4 +--- .../cloud/spanner/SpannerOptionsTest.java | 17 +++++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java index e6f60090acb..3a8632e2ebe 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java @@ -741,9 +741,7 @@ public static class Builder extends ServiceOptions.Builder { static final int DEFAULT_PREFETCH_CHUNKS = 4; static final QueryOptions DEFAULT_QUERY_OPTIONS = QueryOptions.getDefaultInstance(); - // TODO: Set the default to DecodeMode.DIRECT before merging to keep the current default. - // It is currently set to LAZY_PER_COL so it is used in all tests. - static final DecodeMode DEFAULT_DECODE_MODE = DecodeMode.LAZY_PER_COL; + static final DecodeMode DEFAULT_DECODE_MODE = DecodeMode.DIRECT; static final RetrySettings DEFAULT_ADMIN_REQUESTS_LIMIT_EXCEEDED_RETRY_SETTINGS = RetrySettings.newBuilder() .setInitialRetryDelay(Duration.ofSeconds(5L)) diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java index 522cd0147a3..73455f06688 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java @@ -104,16 +104,21 @@ public static void resetLogging() { @Test public void defaultBuilder() { - // We need to set the project id since in test environment we cannot obtain a default project - // id. - SpannerOptions options = SpannerOptions.newBuilder().setProjectId("test-project").build(); + // We need to set the project id and credentials since in test environments we cannot guarantee + // that a default project id and credentials are available. + SpannerOptions options = + SpannerOptions.newBuilder() + .setProjectId("test-project") + .setCredentials(NoCredentials.getInstance()) + .build(); if (Strings.isNullOrEmpty(System.getenv("SPANNER_EMULATOR_HOST"))) { - assertThat(options.getHost()).isEqualTo("https://spanner.googleapis.com"); + assertEquals("https://spanner.googleapis.com", options.getHost()); } else { - assertThat(options.getHost()).isEqualTo("http://" + System.getenv("SPANNER_EMULATOR_HOST")); + assertEquals("http://" + System.getenv("SPANNER_EMULATOR_HOST"), options.getHost()); } - assertThat(options.getPrefetchChunks()).isEqualTo(4); + assertEquals(4, options.getPrefetchChunks()); assertNull(options.getSessionLabels()); + assertEquals(DecodeMode.DIRECT, options.getDecodeMode()); } @Test