Skip to content

Commit 94de7f1

Browse files
tilgalascopybara-github
authored andcommitted
fix: Use ConcurrentHashMap in InvocationReplayState
fixes #1009 PiperOrigin-RevId: 885641755
1 parent 3ba04d3 commit 94de7f1

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

dev/src/main/java/com/google/adk/plugins/InvocationReplayState.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
package com.google.adk.plugins;
1717

1818
import com.google.adk.plugins.recordings.Recordings;
19-
import java.util.HashMap;
2019
import java.util.Map;
20+
import java.util.concurrent.ConcurrentHashMap;
2121

2222
/** Per-invocation replay state to isolate concurrent runs. */
2323
class InvocationReplayState {
@@ -33,7 +33,7 @@ public InvocationReplayState(String testCasePath, int userMessageIndex, Recordin
3333
this.testCasePath = testCasePath;
3434
this.userMessageIndex = userMessageIndex;
3535
this.recordings = recordings;
36-
this.agentReplayIndices = new HashMap<>();
36+
this.agentReplayIndices = new ConcurrentHashMap<>();
3737
}
3838

3939
public String getTestCasePath() {
@@ -57,7 +57,6 @@ public void setAgentReplayIndex(String agentName, int index) {
5757
}
5858

5959
public void incrementAgentReplayIndex(String agentName) {
60-
int currentIndex = getAgentReplayIndex(agentName);
61-
setAgentReplayIndex(agentName, currentIndex + 1);
60+
agentReplayIndices.merge(agentName, 1, Integer::sum);
6261
}
6362
}

0 commit comments

Comments
 (0)