Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit 1c9e480

Browse files
committed
Merge branch 'main' into PR #2663 to update
2 parents 6cd6f04 + 17707be commit 1c9e480

2 files changed

Lines changed: 24 additions & 10 deletions

File tree

google-cloud-bigtable-emulator-core/src/main/java/com/google/cloud/bigtable/emulator/core/EmulatorController.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public class EmulatorController {
4444

4545
private final Path executable;
4646
private Process process;
47+
private Thread stdoutThread;
48+
private Thread stderrThread;
4749
private boolean isStopped = true;
4850
private Thread shutdownHook;
4951

@@ -127,8 +129,8 @@ public synchronized void start(int port)
127129
throw e;
128130
}
129131
}
130-
pipeStreamToLog(process.getInputStream(), Level.INFO);
131-
pipeStreamToLog(process.getErrorStream(), Level.WARNING);
132+
Thread stdoutThread = pipeStreamToLog(process.getInputStream(), Level.INFO);
133+
Thread stderrThread = pipeStreamToLog(process.getErrorStream(), Level.WARNING);
132134
isStopped = false;
133135

134136
shutdownHook =
@@ -164,6 +166,23 @@ public synchronized void stop() {
164166
} finally {
165167
isStopped = true;
166168
process.destroy();
169+
170+
try {
171+
process.waitFor();
172+
if (stdoutThread != null) {
173+
stdoutThread.join();
174+
}
175+
if (stderrThread != null) {
176+
stderrThread.join();
177+
}
178+
} catch (InterruptedException e) {
179+
Thread.currentThread().interrupt();
180+
LOGGER.log(Level.WARNING, "Interrupted while waiting for emulator to stop", e);
181+
} finally {
182+
stdoutThread = null;
183+
stderrThread = null;
184+
process = null;
185+
}
167186
}
168187
}
169188

@@ -239,7 +258,7 @@ private static void waitForPort(int port) throws InterruptedException, TimeoutEx
239258
}
240259

241260
/** Creates a thread that will pipe an {@link InputStream} to this class' Logger. */
242-
private static void pipeStreamToLog(final InputStream stream, final Level level) {
261+
private static Thread pipeStreamToLog(final InputStream stream, final Level level) {
243262
final BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
244263

245264
Thread thread =
@@ -258,6 +277,7 @@ private static void pipeStreamToLog(final InputStream stream, final Level level)
258277
});
259278
thread.setDaemon(true);
260279
thread.start();
280+
return thread;
261281
}
262282
// </editor-fold>
263283
}

pom.xml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,8 @@
263263

264264
<!-- Hide @InternalApi classes for InstanceAdmin -->
265265
<sourceFileExclude>**/com/google/cloud/bigtable/admin/v2/internal/**</sourceFileExclude>
266-
<sourceFileExclude>**/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminCallableFactory.java</sourceFileExclude>
267-
<sourceFileExclude>**/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableInstanceAdminStub.java</sourceFileExclude>
268-
<sourceFileExclude>**/com/google/cloud/bigtable/admin/v2/stub/BigtableInstanceAdminStub.java</sourceFileExclude>
269266

270267
<!-- Hide**/ @InternalApi classes for TableAdmin -->
271-
<sourceFileExclude>**/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminCallableFactory.java</sourceFileExclude>
272-
<sourceFileExclude>**/com/google/cloud/bigtable/admin/v2/stub/GrpcBigtableTableAdminStub.java</sourceFileExclude>
273-
<sourceFileExclude>**/com/google/cloud/bigtable/admin/v2/stub/BigtableTableAdminStub.java</sourceFileExclude>
274268
<sourceFileExclude>**/com/google/cloud/bigtable/admin/v2/stub/EnhancedBigtableTableAdminStub.java</sourceFileExclude>
275269

276270
<!-- Hide**/ @InternalApi classes for Data -->
@@ -327,7 +321,7 @@
327321
<!-- Exclude generating javadocs for internal implementations for admin and data, which
328322
are under internal/ and .v2.stub/, and exclude all BaseClients and BaseSettings.
329323
The only exception is we want to keep the javadoc for StubSettings. -->
330-
-excludeclasses com\.google\.cloud\.bigtable\.admin\.v2\.(internal\.|stub\.(?!Bigtable.*StubSettings).*):com\.google\.cloud\.bigtable\.data\.v2\.(internal\.|(Base.*).*|stub\.(?!Enhanced.*StubSettings).*)
324+
-excludeclasses com\.google\.cloud\.bigtable\.admin\.v2\.internal\..*:com\.google\.cloud\.bigtable\.data\.v2\.(internal\.|(Base.*).*|stub\.(?!Enhanced.*StubSettings).*)
331325
<!-- Exclude the javadocs for the auto-generated raw protos since we don't expose them.
332326
The raw protos generated by gapic are under com.google.bigtable. And the public surface
333327
is under com.google.cloud.bigtable. Also exclude the stats package which is the

0 commit comments

Comments
 (0)