diff --git a/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/storage/ChatSessionStorage.kt b/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/storage/ChatSessionStorage.kt index 0a9a782ecb..0e38f06c6d 100644 --- a/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/storage/ChatSessionStorage.kt +++ b/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/storage/ChatSessionStorage.kt @@ -8,13 +8,8 @@ import software.aws.toolkits.jetbrains.services.amazonqCodeTest.session.Session class ChatSessionStorage { private val sessions = mutableMapOf() - private fun createSession(tabId: String): Session { - val session = Session(tabId) - sessions[tabId] = session - return session - } - - fun getSession(tabId: String): Session = sessions[tabId] ?: createSession(tabId) + @Synchronized + fun getSession(tabId: String): Session = sessions.getOrPut(tabId) { Session(tabId) } fun deleteSession(tabId: String) { sessions.remove(tabId)