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

Commit 320047e

Browse files
committed
test: fix race in emulator controller
1 parent f4398bb commit 320047e

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public class EmulatorController {
4343
private static final Logger LOGGER = Logger.getLogger(EmulatorController.class.getName());
4444

4545
private final Path executable;
46-
private Process process;
47-
private boolean isStopped = true;
46+
private volatile Process process;
47+
private volatile boolean isStopped = true;
4848
private Thread shutdownHook;
4949

5050
private int port;
@@ -134,9 +134,11 @@ public synchronized void start(int port)
134134
shutdownHook =
135135
new Thread(
136136
() -> {
137-
if (!isStopped) {
138-
isStopped = true;
139-
process.destroy();
137+
synchronized (EmulatorController.this) {
138+
if (!isStopped) {
139+
isStopped = true;
140+
process.destroy();
141+
}
140142
}
141143
});
142144

0 commit comments

Comments
 (0)