From d70fc28773cce3e54508e031d196d5f23392f27f Mon Sep 17 00:00:00 2001 From: Thiago Nunes Date: Fri, 13 Nov 2020 09:20:37 +1100 Subject: [PATCH] fix: does not set encryption info if null Does not set encryption info in the request if it is null --- .../cloud/spanner/spi/v1/GapicSpannerRpc.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java index 6daee8fedf..b8d5bd20d3 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java @@ -840,16 +840,15 @@ public OperationFuture createDatabase( final String databaseId = createDatabaseStatement.substring( "CREATE DATABASE `".length(), createDatabaseStatement.length() - 1); - CreateDatabaseRequest request = + CreateDatabaseRequest.Builder requestBuilder = CreateDatabaseRequest.newBuilder() .setParent(instanceName) .setCreateStatement(createDatabaseStatement) - .addAllExtraStatements(additionalStatements) - .setEncryptionConfig( - databaseInfo.getEncryptionConfigInfo() == null - ? null - : databaseInfo.getEncryptionConfigInfo().toProto()) - .build(); + .addAllExtraStatements(additionalStatements); + if (databaseInfo.getEncryptionConfigInfo() != null) { + requestBuilder.setEncryptionConfig(databaseInfo.getEncryptionConfigInfo().toProto()); + } + final CreateDatabaseRequest request = requestBuilder.build(); OperationFutureCallable callable = new OperationFutureCallable(