Skip to content

Commit e99b78c

Browse files
authored
fix: add ensureDecoded to proto type (#2897)
* fix(spanner): add ensureDecoded to proto type * fix(spanner): negate condition and name
1 parent 18d4dd9 commit e99b78c

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ protected <T extends AbstractMessage> T getProtoMessageInternal(int columnIndex,
373373
Preconditions.checkNotNull(
374374
message,
375375
"Proto message may not be null. Use MyProtoClass.getDefaultInstance() as a parameter value.");
376+
ensureDecoded(columnIndex);
376377
try {
377378
return (T)
378379
message

google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITProtoColumnTest.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import static org.junit.Assert.assertNotNull;
2222
import static org.junit.Assert.assertThrows;
2323
import static org.junit.Assume.assumeFalse;
24+
import static org.junit.Assume.assumeTrue;
2425

2526
import com.google.cloud.ByteArray;
2627
import com.google.cloud.spanner.Database;
@@ -54,14 +55,12 @@
5455
import org.junit.AfterClass;
5556
import org.junit.BeforeClass;
5657
import org.junit.ClassRule;
57-
import org.junit.Ignore;
5858
import org.junit.Test;
5959
import org.junit.experimental.categories.Category;
6060
import org.junit.runner.RunWith;
6161
import org.junit.runners.JUnit4;
6262

6363
// Integration Tests to test DDL, DML and DQL for Proto Columns and Enums
64-
@Ignore("Feature is not yet enabled in production")
6564
@Category(ParallelIntegrationTest.class)
6665
@RunWith(JUnit4.class)
6766
public class ITProtoColumnTest {
@@ -71,10 +70,17 @@ public class ITProtoColumnTest {
7170
private static DatabaseAdminClient dbAdminClient;
7271
private static DatabaseClient databaseClient;
7372

73+
public static boolean isUsingAllowlistedProject() {
74+
String projectId = System.getProperty("spanner.gce.config.project_id", "");
75+
return projectId.equalsIgnoreCase("gcloud-devel")
76+
|| projectId.equalsIgnoreCase("span-cloud-testing");
77+
}
78+
7479
@BeforeClass
7580
public static void setUpDatabase() throws Exception {
7681
assumeFalse(
7782
"Proto Column is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator());
83+
assumeTrue("Proto Column is not yet enabled in production", isUsingAllowlistedProject());
7884
RemoteSpannerHelper testHelper = env.getTestHelper();
7985
databaseID = DatabaseId.of(testHelper.getInstanceId(), testHelper.getUniqueDatabaseId());
8086
dbAdminClient = testHelper.getClient().getDatabaseAdminClient();
@@ -133,7 +139,7 @@ public static void createDatabase() throws Exception {
133139
@AfterClass
134140
public static void afterClass() throws Exception {
135141
try {
136-
if (!isUsingEmulator()) {
142+
if (!isUsingEmulator() && isUsingAllowlistedProject()) {
137143
dbAdminClient.dropDatabase(
138144
databaseID.getInstanceId().getInstance(), databaseID.getDatabase());
139145
}
@@ -163,6 +169,7 @@ public void after() throws Exception {
163169
public void testProtoColumnsUpdateAndRead() {
164170
assumeFalse(
165171
"Proto Column is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator());
172+
assumeTrue("Proto Column is not yet enabled in production", isUsingAllowlistedProject());
166173
SingerInfo singerInfo =
167174
SingerInfo.newBuilder().setSingerId(1).setNationality("Country1").build();
168175
ByteArray singerInfoBytes = ByteArray.copyFrom(singerInfo.toByteArray());
@@ -270,6 +277,7 @@ public void testProtoColumnsUpdateAndRead() {
270277
public void testProtoColumnsDMLParameterizedQueriesPKAndIndexes() {
271278
assumeFalse(
272279
"Proto Column is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator());
280+
assumeTrue("Proto Column is not yet enabled in production", isUsingAllowlistedProject());
273281

274282
SingerInfo singerInfo1 =
275283
SingerInfo.newBuilder().setSingerId(1).setNationality("Country1").build();
@@ -376,6 +384,7 @@ public void testProtoColumnsDMLParameterizedQueriesPKAndIndexes() {
376384
public void testProtoMessageDeserializationError() {
377385
assumeFalse(
378386
"Proto Column is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator());
387+
assumeTrue("Proto Column is not yet enabled in production", isUsingAllowlistedProject());
379388

380389
SingerInfo singerInfo =
381390
SingerInfo.newBuilder().setSingerId(1).setNationality("Country1").build();

0 commit comments

Comments
 (0)