Skip to content

Prevent concurrent mutation in Google GenAI dimension lookup - #6769

Open
dangzitou wants to merge 1 commit into
spring-projects:mainfrom
dangzitou:chore/fix-google-genai-dimension-cache
Open

Prevent concurrent mutation in Google GenAI dimension lookup#6769
dangzitou wants to merge 1 commit into
spring-projects:mainfrom
dangzitou:chore/fix-google-genai-dimension-cache

Conversation

@dangzitou

Copy link
Copy Markdown

Summary

Issue

Closes #6763

Change

The current computeIfAbsent call on a shared mutable HashMap can throw ConcurrentModificationException under concurrent access when multiple unknown model names are requested simultaneously. This change removes side-effectful map writes from the hot path by querying dimensions once and only assigning via the existing fallback path.

Why

  • Applies first-principles reasoning on concurrency: mutable shared state should not be modified without proper synchronization in read-mostly paths.
  • Preserves behavior for all known-model names and removes rare concurrency crash class.

Validation

  • Static concurrency and control-flow review of dimensions() branching.
  • Manually reasoned equivalent outputs for supported models.
  • mvn test / full project CI not run in this environment.

Signed-off-by: Dang Zitou <dengzitao888@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GoogleGenAiTextEmbeddingModel.dimensions() mutates a shared static HashMap, throwing ConcurrentModificationException under concurrent use

2 participants