Skip to content

Commit f5adf3d

Browse files
committed
Fix snippets
1 parent 006d60d commit f5adf3d

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

google-cloud-examples/src/main/java/com/google/cloud/examples/spanner/snippets/DatabaseAdminClientSnippets.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.util.ArrayList;
3535
import java.util.Arrays;
3636
import java.util.List;
37+
import java.util.concurrent.ExecutionException;
3738

3839
/**
3940
* This class contains snippets for {@link DatabaseAdminClient} interface.
@@ -71,14 +72,13 @@ public Database createDatabase(String instanceId, String databaseId) {
7172
+ " AlbumTitle STRING(MAX)\n"
7273
+ ") PRIMARY KEY (SingerId, AlbumId),\n"
7374
+ " INTERLEAVE IN PARENT Singers ON DELETE CASCADE"));
74-
Database db;
7575
try {
76-
db = op.get();
77-
} catch (Exception e) {
78-
throw SpannerExceptionFactory.newSpannerException(e);
76+
return op.get();
77+
// [END createDatabase]
78+
} catch (ExecutionException | InterruptedException e) {
79+
// DO error handing
7980
}
80-
// [END createDatabase]
81-
return db;
81+
return null;
8282
}
8383

8484
/**
@@ -107,8 +107,8 @@ public void updateDatabaseDdl(String instanceId, String databaseId) {
107107
databaseId,
108108
Arrays.asList("ALTER TABLE Albums ADD COLUMN MarketingBudget INT64"),
109109
null).get();
110-
} catch (Exception e) {
111-
throw SpannerExceptionFactory.newSpannerException(e);
110+
} catch (ExecutionException | InterruptedException e) {
111+
// DO error handling
112112
}
113113
// [END updateDatabaseDdl]
114114
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void getDatabase() {
8686
assertThat(db.getState()).isEqualTo(DatabaseInfo.State.READY);
8787
}
8888

89-
@Test(timeout = 1000)
89+
@Test
9090
public void createDatabase() throws Exception {
9191
OperationFuture<Database, CreateDatabaseMetadata> rawOperationFuture =
9292
OperationFutureUtil.immediateOperationFuture(
@@ -117,6 +117,7 @@ public void updateDatabaseDdl() throws Exception {
117117

118118
@Ignore("More work needs to be done")
119119
@Test
120+
// TODO(hzyi)
120121
// Changing the surface to OperationFuture breaks updateDatabaseDdl in the case
121122
// that there is already a longrunning operation running. Disabling this test for
122123
// this PR and I will fix this in the next PR.

0 commit comments

Comments
 (0)