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

Commit d5d3975

Browse files
authored
chore: prevent start and stop to run in parallel (#4335)
Synchronize the start() and stop() methods of the session maintainer to prevent them from running at the same time. That could cause a data race on the scheduled future that the start() method sets, and the stop() method reads.
1 parent aa53a43 commit d5d3975

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ final class MultiplexedSessionMaintainer {
562562
this.clock = clock;
563563
}
564564

565-
void start() {
565+
private synchronized void start() {
566566
// Schedule the maintainer to run once every ten minutes (by default).
567567
long loopFrequencyMillis =
568568
MultiplexedSessionDatabaseClient.this
@@ -577,7 +577,7 @@ void start() {
577577
this::maintain, loopFrequencyMillis, loopFrequencyMillis, TimeUnit.MILLISECONDS);
578578
}
579579

580-
void stop() {
580+
private synchronized void stop() {
581581
if (this.scheduledFuture != null) {
582582
this.scheduledFuture.cancel(false);
583583
}

0 commit comments

Comments
 (0)